現象
[root@ln0-181 src]# docker login harbor.spos.lab
Authenticating with existing credentials...
Login did not succeed, error: Error response from daemon: login attempt to http://harbor.spos.lab/v2/ failed with status: 502 Bad Gateway
Username (admin): admin
Password:
Error response from daemon: login attempt to http://harbor.spos.lab/v2/ failed with status: 502 Bad Gateway
排查
# 1. 直接請求harbor接口可以訪問, 通過nginx代理不通
[root@ln0-181 conf.d]# curl -I http://harbor.spos.lab:180/harbor/sign-in
HTTP/1.1 200 OK
[root@ln0-181 conf.d]# curl -I http://harbor.spos.lab:80/harbor/sign-in
HTTP/1.1 502 Bad Gateway
# 2. nginx配置及啟動沒有問題
# 3. 查看nginx error日志
2021/05/13 09:54:17 [crit] 32484#0: *3 connect() to 127.0.0.1:180 failed (13: Permission denied) while connecting to upstream, client: 172.19.0.181, server: harbor.spos.lab, request: "HEAD /harbor/sign-in HTTP/1.1", upstream: "http://127.0.0.1:180/harbor/sign-in", host: "harbor.spos.lab"
# 4. 查看防火牆及selinux
[root@ln0-181 nginx]# getenforce
Enforcing
[root@ln0-181 nginx]# setenforce 0
[root@ln0-181 nginx]# getenforce
Permissive
驗證
[root@ln0-181 nginx]# curl -I http://harbor.spos.lab/harbor/sign-in
HTTP/1.1 200 OK