This article mainly explains Nginx as a front-end Web server, tomcat as a back-end application server, all external network requests from Nginx to the intranet tomcat processing, that is, Nginx will request reverse proxy to Tomcat, or nginx+ The load balancing of Tomcat. Nginx version 1.9.12,tomcat version 7.0.4.2
Load-balanced Nginx configuration and static file separation
Upstream Tomcat_cluster {server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=30s;server 127.0.0.1:8081 weight=1 Max _fails=2 fail_timeout=30s;} server { listen; server_name www.yddsj.com; Index index.jsp index.html index.htm; #发布目录/www/yddsj root /www/yddsj; Location/ {# tomcat_cluster must be the same as upstream's name Proxy_pass http://tomcat_cluster;proxy_next_upstream http_502 http_ 504 Error Timeout Invalid_header;proxy_set_header remote-host $remote _addr;proxy_set_header HOST $host; Proxy_set_header x-real-ip $remote _addr;proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; Client_max_body_size 100m; #expires定义用户浏览器缓存的时间为10天expires 10d; } #配置Nginx动静分离则加入以下的配置location ~* \. (Html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar) ${root/www/yddsj;expires 10d;}}
The above describes the Nginx Tomcat load balancing static file separation, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.