在 CentOS 7 上使用 Nginx 作为反响代理连接到后端服务时,发生如下错误,以前一直在用 Ubuntu 系列做服务器,很少用 CentOS,我也验证了这个配置文件在 Ubutu 上运行良好,在 google 上看到了这个错误的解释,使用如下命令可以解决:setsebool -P httpd_can_network_connect 1
2018/08/17 08:49:45 [error] 10488#10488: *4 no live upstreams while connecting to upstream, client: 10.0.15.42, server: 10.0.15.39, request: "GET /Home/Index HTTP/1.1", upstream: "http://localhost/Home/Index", host: "10.0.15.39"
2018/08/17 08:56:31 [crit] 10488#10488: *5 connect() to [::1]:60004 failed (13: Permission denied) while connecting to upstream, client: 10.0.21.92, server: 10.0.15.39, request: "GET / HTTP/1.1", upstream: "http://[::1]:60004/", host: "10.0.15.39"
2018/08/17 08:56:31 [warn] 10488#10488: *5 upstream server temporarily disabled while connecting to upstream, client: 10.0.21.92, server: 10.0.15.39, request: "GET / HTTP/1.1", upstream: "http://[::1]:60004/", host: "10.0.15.39"
2018/08/17 08:56:31 [crit] 10488#10488: *5 connect() to 127.0.0.1:60004 failed (13: Permission denied) while connecting to upstream, client: 10.0.21.92, server: 10.0.15.39, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:60004/", host: "10.0.15.39"
2018/08/17 08:56:31 [warn] 10488#10488: *5 upstream server temporarily disabled while connecting to upstream, client: 10.0.21.92, server: 10.0.15.39, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:60004/", host: "10.0.15.39"
2018/08/17 08:56:32 [error] 10488#10488: *5 no live upstreams while connecting to upstream, client: 10.0.21.92, server: 10.0.15.39, request: "GET / HTTP/1.1", upstream: "http://localhost/", host: "10.0.15.39"
反响代理配置如下:
server {
listen 80;
server_name 10.0.15.39;
location /shares {
root /data/minio/data;
autoindex on;
}
location /nginx {
root /usr/share/nginx/html;
autoindex on;
index index.html index.htm;
}
location / {
proxy_pass http://localhost:60004;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
网友评论