Develop/기타 작업
Nginx Error Page (html)처리
팡연
2022. 11. 3. 21:49
반응형
Nginx Error Page 처리방법으로는 error_page를 먼저 선언하고 뒤에 에러코드
그리고 표시할 html 파일 이름을 작성한 후 location을 선언한다.
location 안에는 html 파일경로를 작성한다.
또한, 한번에 여러 에러를 같은 페이지로 처리하기 위해서는 500 501 502 이런식으로 선언하여 사용한다.
server {
error_page 400 /error_400.html;
location = /error_400.html {
root /usr/error/;
}
error_page 404 /error_404.html;
location = /error_404.html {
root /usr/error/;
}
error_page 500 501 502 /error_500.html;
location = /error_500.html {
root /usr/error/;
}
}
간혹 에러페이지를 선언하였지만, 해당 에러페이지로 가지 않을 땐
발생하는 해당 location에 proxy_intercept_errors on;을 선언한다.
server {
error_page 400 /error_400.html;
location = /error_400.html {
root /usr/error/;
}
error_page 404 /error_404.html;
location = /error_404.html {
root /usr/error/;
}
error_page 500 501 502 /error_500.html;
location = /error_500.html {
root /usr/error/;
}
location /api/test {
proxy_intercept_errors on;
}
}
반응형