[Docker][502에러] nginx 로 reverse proxy 구성해서 postgresql을 위한 pgadmin 웹페이지에 접속하기.
nginx.conf 파일의 location을 다음과 같이 구성하면 '502 Bad Gateway'에러가 남.
1
2
3
4
5
6
7
8
9
10
location /pgadmin/ {
rewrite ^/pgadmin(.*)$ $1 break;
proxy_pass http://docker-pgadmin;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
여러 시행착오 끝에 다음과 같이 하니 성공하였음…
1
2
3
4
5
6
7
8
9
10
location /pgadmin {
proxy_pass http://docker-pgadmin;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Script-Name /pgadmin;
}
ip주소/pgadmin 으로 들어가면, 성공!
** X-Script-Name을 **/pgadmin; 로 넣어줬고, rewrite 를 빼는게 핵심. 더 많은 테스트는 무리임..ㅠ
같은 문제상황인 분들은 참고만 하시길 바랍니다. ㅎㅎ 감사합니다.
https://devpress.csdn.net/cloud/62fc8ee57e6682346619006c.html https://postgrespro.com/list/thread-id/2428819
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.



