Nginx SSL 적용 http https 리다이렉트/리디랙션 처리
http://[example.com] 로 접근 시, http 부분을 조회하여 https로 retrun 해주는 구문을 nginx로 적용.
server {
...
server_name example.com;
if ($http_x_forwarded_proto = 'http'){
return 301 https://$host$request_uri;
}
location / {
proxy_pass http://tomcat;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* \.(gif|jpg|png|js|css) {
access_log off;
proxy_pass http://tomcat;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server_name 아래로,
if ($http_x_forwarded_proto = 'http'){
return 301 https://$host$request_uri;
}
부분을 추가해주고 nignx 서버를 재시작.
[CENTOS 6.9 기준] service nginx restart
완료.
'개발자' 카테고리의 다른 글
퇴근까지 3시간이 남았는데요, 뭘 해볼까요. (0) | 2020.08.04 |
---|---|
아, 뭐해먹고 살아야 할까요? 서른 개발자. (0) | 2020.08.04 |
Nginx + tomcat9 연동 - Centos6.9 환경 (0) | 2020.05.08 |
Nginx 설치 - Centos 6.9 환경 (0) | 2020.05.08 |
JSTL 부등호 gt lt eq (0) | 2019.08.09 |