채택완료
nginx 에서 IP주소로 접속시 return
안녕하세요!!
http://xxx.xxx.xxx.xxx ip주소로 접속시 아래처럼 하면 404 에러페이지를 보여줍니다.
server {
listen 80 default;
listen [::]:80 default;
return 404;
}
그런데, 위와 같이 하면 http에서만 작동되더군요.
https://xxx.xxx.xxx.xxx 처럼 https 아이피주소로 접속시에도 404로 처리하려면 어떻게 해야 하나요?
미리 감사드립니다.
답변 2개 / 댓글 8개
채택된 답변
+20 포인트
Copy
server {
listen 443 default;
listen [::]:443 default;
return 404;
}
답변에 대한 댓글 3개
보니까..
이렇게 포트가 2개로 이루어진거 아녀요? 여기서 접속할때 http 에 따로 리다이렉트 하고
https도 마찬가지로 리다이렉트해서 하는건 아닌가요?
server {
listen 80;
server_name domain.com;
}
server {
listen 443;
server_name domain.com;
}
답변에 대한 댓글 5개
답변을 작성하려면 로그인이 필요합니다.
위 내용은 추가 하고 nginx 재식작 하면 아래와 같은 메세지가 나옵니다.
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
"journalctl -xe" 로 화인해보면 아주~~~~~~~~~~~~~~긴 내용이 나오는데 무슨 내용인지 모르겠습니다. ㅎ... 마지막 몇줄만 올려볼게요.
-- The unit nginx.service has successfully entered the 'dead' state.
Feb 20 20:26:31 carway systemd[1]: Stopped A high performance web server and a reverse proxy server.
-- Subject: A stop job for unit nginx.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit nginx.service has finished.
--
-- The job identifier is 488999 and the job result is done.
Feb 20 20:26:31 carway systemd[1]: Starting A high performance web server and a reverse proxy server...
-- Subject: A start job for unit nginx.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit nginx.service has begun execution.
--
-- The job identifier is 488999.
Feb 20 20:26:31 carway nginx[832423]: nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /et>
Feb 20 20:26:31 carway nginx[832423]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 20 20:26:31 carway systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStartPre= process belonging to unit nginx.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Feb 20 20:26:31 carway systemd[1]: nginx.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit nginx.service has entered the 'failed' state with result 'exit-code'.
Feb 20 20:26:31 carway systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: A start job for unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit nginx.service has finished with a failure.