(13: Permission denied) while connecting to upstream

在 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;
        }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 记得上一次写年度总结已是五年前了,加入007第一篇就写总结。 一,运动 今年原计划是少吃多运动,但是实际是多吃运...
    壮_0a70阅读 134评论 0 1
  • 人们对于区块链的疯狂正如当初对于互联网的疯狂一样,而盲目的热情、迷茫的未来都在让很多投身区块链的人们一时间难以找到...
    产业深观阅读 400评论 1 2
  • 炎热的夏日似乎要把茵子吞了,已经好久没有很父母闹过矛盾,可她还是抵不过内心的敏感。事情已经发生了,无疑会给茵子...
    敢问一声阅读 216评论 0 1