fzy-blog

Centos nginx 负载均衡+动静分离配置

2019-05-24

Centos nginx 负载均衡+动静分离配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
   upstream tomcat_server {
server 192.168.1.231:8080 weight=1;
server 192.168.1.232:8080 weight=1;
}

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://tomcat_server;
}

#动态访问转向tomcat处理
#location ~ \.(jsp|page|do)?$ {
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_pass http://tomcat_server;
#}

#设定访问静态文件直接读取不经过tomcat
location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
Tags: Linux
使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏

扫描二维码,分享此文章