컴퓨터공학 기초/인프라
[nginx] error code 별로 error page 보여주기
상용최
2021. 2. 28. 03:06
반응형
에러코드별로 별도의 에러페이지를 보여줘야 할 때가 많다.
nginx 를 이용하여 간편하게 처리할 수 있다.
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
error_page 403 404 /custom_404.html;
location = /custom_404.html {
root 에러페이지 있는 경로;
internal;
}
}
}
위와같이 한다면 403 에러와 404에러일 때 custom_404.html 를 보여주게 된다.
서비스 장애가나서 급하게 에러페이지를 다른것으로 대체해야 할 때 이용할 수 있을 것 같다.
반응형