NGINX 에러페이지 설정하기

2025-09-10 14:52
5
0
0
0
본문
접기
[ ▼ 작성자 참고 Source ]
server { listen 80; server_name example.com; root /data/www; # 클라이언트 에러 (404, 403) error_page 403 /403.html; error_page 404 /404.html; location = /403.html { root /data/www/errors; internal; } location = /404.html { root /data/www/errors; internal; } # 서버 에러 (500, 502, 503, 504) error_page 500 502 503 504 /50x.html; location = /50x.html { root /data/www/errors; internal; } }
본문
NGINX에서는 지시어를 통해 특정 상태코드가 발생했을때 NGINX가 내부적으로 이동할 URI를 지정할수 있습니다
error_page 지시어 뒤에 상태코드와 URL을 지정하여 접속한 사용자에게 리다이렉트를 할수 있습니다
클라이언트 에러 페이지
403: 권한 없음 → /data/www/errors/403.html
404: 페이지 없음 → /data/www/errors/404.html
서버 에러 페이지
500: Internal Server Error
502: Bad Gateway
503: Service Unavailable
504: Gateway Timeout
→ 모두 /data/www/errors/50x.html 로 안내
internal; 옵션
직접 http://example.com/50x.html 이런 식으로 접근은 못하게 막고, nginx가 내부에서만 호출할 수 있도록 제한
0
0
로그인 후 추천 또는 비추천하실 수 있습니다.
댓글목록0