예를 들어,
https://eond.com
https://www.eond.com
https://eond.com/bbs
https://eond.com/?mid=bbs
이런 주소로 접속했을 경우
자동으로 https를 http로 고쳐주는 방법이 무엇인까요?
nginx rewiterule 설정이 아직 잘 모르겠습니다.
nginx.conf 에서 지금은
server {
..
}
이 사이에
# if ($http_host = "www.eond.com") { # rewrite ^ http://eond.com$request_uri permanent; # }
이렇게 하는 것 밖에 잘 모르겠습니다.
HTTPS를 별도의 server로 잡아서 몽땅 리다이렉트해버리면 됩니다.
물론 SSL 인증서는 제대로 설치되어 있어야 하고요.
nginx에서 if나 rewrite는 웬만하면 피하는 것이 좋아요.
server를 여러 개 선언하는 것이 훨씬 효율적이거든요.
server {
listen 80;
server_name eond.com www.eond.com;
# ... root, index, PHP 연동, 캐싱 등 나머지 설정 ...
}
server {
listen 443 ssl;
server_name eond.com www.eond.com;
location / {
return 301 http://$host$request_uri;
expires epoch;
}
# ... SSL 인증서 설정 ...
}