时间:2021-07-01 10:21:17 帮助过:24人阅读
负载均衡nginx配置以及静态文件分离
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 80; server_name www.yddsj.com; index index.jsp index.html index.htm; #发布目录 /www/yddsj root /www/yddsj; location / { # tomcat_cluster必须和upstream的名称一样 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; } }
以上就介绍了Nginx Tomcat 负载均衡搭建 静态文件分离,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。