: This article describes how to set up static file separation for NginxTomcat server load balancer. if you are interested in PHP tutorials, refer to it. This article mainly explains how to use Nginx as the front-end web server and tomcat as the backend application server. all Internet requests are forwarded from nginx to the intranet tomcat for processing, that is, nginx Reverse proxy requests to tomcat, or nginx + tomcat load balancing. Nginx version 1.9.12 and tomcat version 7.0.4.2
Server load balancer nginx configuration and static file separation
Upstream tomcat_cluster {server 127.0.0.1: 8080 weight = 1 max_fails = 2 fail_timeout = 30 s; server 127.0.0.1: 8081 weight = 1 max_fails = 2 fail_timeout = 30 s;} server {listen 80; server_name www.yddsj.com; index. jsp index.html index.htm; # release directory/www/yddsj root/www/yddsj; location/{# tomcat_cluster must be the same as upstream 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 $ scheme; limit 100 m; # expires defines that the cache time of your browser is 10 days expires 10 days;} # add the following configuration location to Configure Nginx static/dynamic separation ~ *\. (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 preceding section describes how to set up static file separation for Nginx Tomcat server load balancer, including some content. if you are interested in the PHP Tutorial.