nginx + tomcat 配置,静态资源直接使用nginx
upstream tomcat_server { server 127.0.0.1:8080; } server { listen 80; server_name localhost;root D:\work\my-project; location / {index index.jsp;}location /j_spring_security_check {proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://tomcat_server;} location ~ .*\.(jsp|do)$ { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://tomcat_server; }location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ #设定访问静态文件直接读取不经过tomcat{expires 30d;}location ~ ^/(WEB-INF)/ { #这个很重要,不然用户就可以访问了 deny all; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }