配置看了好久没啥问题啊,跟着网上的帖子做的,各位大佬帮忙看看吧,求求了
4条回答 默认 最新
- liyanjing1210 2020-03-25 11:42关注
服务器集群名称,采用负载策略是轮询权重
upstream balance.com {
server 172.16.100.7:8001 weight=1 max_fails=3 fail_timeout=30s;
server 172.16.100.8:8001 weight=2 max_fails=3 fail_timeout=30s down;
}
server {
listen 80;
server_name 127.0.0.1;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
#将请求转向 balance.com 定义的服务器列表
proxy_pass http://balance.com;#允许重新定义或添加字段传递给代理服务器的请求头,请阅读proxy_set_header #端口号是容器对应的宿主机的port proxy_set_header Host $host:80; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Via "nginx"; proxy_set_header Cookie $http_cookie; proxy_redirect off; #expires 1d; }
}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报