nginx 配置反向代理后响应502解决办法

问题

在配置反响代理到本地 127.0.0.1:7788 这个地址后,请求 nginx 地址响应 502 查看 /var/log/nginx/error.log 日志文件提示如下:

2022/11/19 08:51:11 [crit] 4210#0: *1 connect() to 127.0.0.1:7788 failed (13: Permission denied) while connecting to upstream, client: 20.222.186.137, server: ntfy.greycode.top, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:7788/", host: "test.com"

解决

根据stackoverflow的回答,执行如下命令解决问题

setsebool -P httpd_can_network_connect 1
Published At