use*_*er1 7 nginx node.js centos7
我正在尝试在 CentOS 7 上运行的 Nginx 服务器上运行多个 Nodejs 应用程序。我注意到,当我在某些端口上运行 Nodejs 应用程序时,我在浏览器中收到 502 Bad Gateway 错误,因此我检查了错误日志:
[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"
Run Code Online (Sandbox Code Playgroud)
例如,当我更改应用程序以收听 8008 时,一切正常。我检查了权限,如果进程以 root 身份运行并且一切正常。我也玩了超时但没有结果。任何人都可以帮忙吗?
Mic*_*ton 24
默认情况下,SELinux 只允许 Web 服务器与一组有限的端口建立出站连接。
# semanage port --list
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
Run Code Online (Sandbox Code Playgroud)
要解决此问题,您只需将自己想要的端口号添加到列表中。
# semanage port --add --type http_port_t --proto tcp 7777
Run Code Online (Sandbox Code Playgroud)
然后您将看到添加到列表中的端口号,然后您的连接应该可以工作了。
# semanage port --list
http_port_t tcp 7777, 80, 81, 443, 488, 8008, 8009, 8443, 9000
Run Code Online (Sandbox Code Playgroud)