-
ACM, ALB, Nginx https 502 Error카테고리 없음 2023. 2. 7. 16:49
원인 : nginx 인바운드 포트를 80으로 개발해둔 상태, 443 포트에 대한 어떠한 처리도 설정하지 않았다.
해결 : ALB 인바운드 포트 80,443 포트를 모두 nginx 80포트로 연결한 후 nginx.conf 파일에서 http일 경우 https로 리디렉션 시켜 문제를 해결
1. elb 80, 443포트 nginx 80포트로 포트포워딩
2. nginx.conf 파일 수정
# nginx.conf server { listen 80; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; # redirect https setting if ($http_x_forwarded_proto != 'https') { return 301 https://$host$request_uri; } location / { proxy_pass http://127.0.0.1:3000; } error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
3. nginx 재시작
sudo service nginx restart
도메인접속, http://도메인, https://도메인 모두 정상 작동 확인