nginx http -> https 리다이렉트 적용하였는데 에러가 납니다.
CMS/프레임워크 | Rhymix 2.0 |
---|---|
개발 언어 | PHP 7.4 |
문제 페이지 주소 | 비공개 (작성 후 5일 경과) |
9tschool.net 접속이 자꾸 http로 되어서 https로 리다이렉트를 하려고
nginx default 값을 수정하였습니다.
글은 https://xetown.com/tips/1172256를 참고하였습니다.
그런데 service nginx restart 를 하면 에러를 뿜어냅니다.
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
system ctl star nginx.service 를 쳐보니 다음과 같은 에러가 떴습니다.
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-08-19 21:03:41 KST; 1min 1s ago
Docs: man:nginx(8)
Process: 335778 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)8월 19 21:03:41 dm1629202418668 systemd[1]: Starting A high performance web server and a reverse proxy server...
8월 19 21:03:41 dm1629202418668 nginx[335778]: nginx: [emerg] a duplicate default server for 0.0.0.0:80 in /etc/nginx/>
8월 19 21:03:41 dm1629202418668 nginx[335778]: nginx: configuration file /etc/nginx/nginx.conf test failed
8월 19 21:03:41 dm1629202418668 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
8월 19 21:03:41 dm1629202418668 systemd[1]: nginx.service: Failed with result 'exit-code'.
8월 19 21:03:41 dm1629202418668 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
예상 되는 원인은
https://xetown.com/tips/1172256 이 글에서 서버 설정시 'default 설정에 유의'하세요 라고 적어주셨는데 그 내용을 이해못해서 저는 그냥 놔둬서이지 않을까 라고 추측을 하고 있습니다.
제가 쓴 코드는 아래와 같습니다.
listen 443 ssl http2;
server_name 9tschool.net;
root /var/www/html/;
charset utf-8;
# XE rewrite 설정
# PHP-FPM 연동 설정
# SSL 인증서 설정
}
server {
listen 443 ssl http2 default;
server_name www.9tschool.net;
location / {
return 301 https://9tschool.net$request_uri;
expires epoch;
}
# 이곳에서는 사이트 경로 설정이나 XE 설정, PHP 연동 설정 등을 하지 않음
# SSL 인증서 설정은 위와 동일하게 해야 함
}
server {
listen 80 default;
server_name 9tschool.net www.9tschool.net;
location / {
return 301 https://9tschool.net$request_uri;
expires epoch;
}
# 이곳에서는 사이트 경로 설정이나 XE 설정, PHP 연동 설정 등을 하지 않음
# 단, Let's Encrypt 인증서 발급을 위해 /.well-known/ 폴더는 특별 처리해도 무방함
}
어떻게 수정해야 할까요??
댓글 5
32번째 줄에 default 빼세요.