Java code
- Upstream Tomcat_server {
- Server 127.0. 0.1:8080;
- }
- server {
- Listen ;
- 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)/{#这个很重要, otherwise users can access the
- Deny all;
- }
- Error_page 502 503 504 /50x.html;
- Location =/50x.html {
- root HTML;
- }
- }
The above describes the Nginx + Tomcat configuration, static resources directly using Nginx, including the Tomcat configuration aspects, I hope that the PHP tutorial interested in a friend helpful.