配置看了好久没啥问题啊,跟着网上的帖子做的,各位大佬帮忙看看吧,求求了
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;
}
}
server_name里一般都是写域名,或者写localhost,写个nginxDemo是什么鬼
nginxDemo 如果不是机器名,一定是这错误了。否则可以看看局域网的那个8080 是否通