當我使用 nginx 對 localhost:8080 进行反向代理时,收到 503 响应。检查 nginx error log,发现有:
[crit] 10000#0: *3 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream, client: ***, server: ***, request: "GET /x/ HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "***"
经过检查,发现是 SELinux 策略阻止了 nginx 访问 上游接口。
可进行如下操作:
sestatus
getenforce
setenforce 0 //臨時禁用
vim /etc/selinux/config //于配置文件中禁用