Nodejs Nginx error: (13: Permission denied) while connecting to upstream

分享于 

2分钟阅读

互联网

  繁體

问题:


[notice] 12806#0: signal process started


[crit] 12807#0: *13 connect() to 127.0.0.1:7777 failed (13: Permission denied) while connecting to upstream, client: **.**.99.58, server: myapp.com, request:"GET / HTTP/1.1", upstream:"http://127.0.0.1:7777/", host:"myapp.com"


[crit] 12807#0: *13 connect() to [::1]:7777 failed (13: Permission denied) while connecting to upstream, client: **.**.99.58, server: myapp.com, request:"GET / HTTP/1.1", upstream:"http://[::1]:7777/", host:"myapp.com"



当我更改应用程序以监听8008时,一切正常,我检查了权限,如果进程作为root运行,一切正常,谁能帮助我?


答案1:

默认情况下,SELinux只允许web服务器建立到一组有限端口的出站连接。


# semanage port --list


http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000



要解决这个问题,只需将你自己的端口号添加到列表中。


# semanage port --add --type http_port_t --proto tcp 7777



然后你将看到添加到列表中的端口号,然后你的连接应该工作。


# semanage port --list


http_port_t tcp 7777, 80, 81, 443, 488, 8008, 8009, 8443, 9000