티스토리 뷰
일반적으로 사용자의 요청에 대한 error 가 발생되면 origin 서버에서 error page를 rendering 하여 응답하게 된다.
만약 proxy 환경이라면 이를 proxy 서버에서 처리할수 있게 설정이 가능하다.
location ~ \.(7z|avi|avif|apkbin|bmp|bz2|png|...|jpg)$ {
...
proxy_pass http://192.168.1.1;
proxy_intercept_errors on;
error_page 404 500 501 502 503 /error_page.html;
...
}
location = /error_page.html {
root /tmp; ## <== /tmp/error_page.html 파일을 error page로 사용한다는 가정하에
internal;
}
테스트 용도이기에 error_page.html는 다음과 같이 간단하게 작성했다.
bash-5.1$ cat /tmp/error_page.html
<html>
error by jacobbaek
</html>
이후 요청을 보내면 다음과 같이 앞서 추가했던 html page를 응답하게 된다.
jacob@localhost:~/workspace$ curl -sk -X GET -D- https://proxy-test.jacobbaek.com/test_img.png
HTTP/2 404
date: Thu, 03 Mar 2022 05:22:09 GMT
content-type: text/html
content-length: 31
etag: "62204472-1f"
<html>
error by jacobbaek
</html>
비교를 위해 기존 error page는 nginx 기본 에러 페이지였다.
jacob@localhost:~/workspace$ curl -sk -X GET -D- https://proxy-test.jacobbaek.com/test_img.png
HTTP/2 404
date: Thu, 03 Mar 2022 05:09:05 GMT
content-type: text/html
content-length: 146
etag: "62204472-1f"
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
참고로 internal 지시자는 사용자가 직접 호출할때는 response를 제공하지 않고
내부적으로 요청이 전달될 경우 처리될수 있도록 하는 지시자이다.
'Server > WebServer' 카테고리의 다른 글
How to use nginx lua module (0) | 2022.02.21 |
---|---|
serve single file on NGINX (0) | 2021.03.23 |
print local ip address and hostname using php on httpd (0) | 2017.04.17 |
Apache Traffic Server (ATS) (0) | 2014.04.29 |
apache httpd module (0) | 2012.04.03 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- openstack backup
- jenkins
- aquasecurity
- mattermost
- kubernetes
- ansible
- K3S
- vmware openstack
- nginx-ingress
- kata container
- boundary ssh
- OpenStack
- wsl2
- socket
- azure policy
- kubernetes install
- Terraform
- GateKeeper
- Jenkinsfile
- metallb
- minio
- hashicorp boundary
- crashloopbackoff
- ceph
- minikube
- open policy agent
- macvlan
- Helm Chart
- DevSecOps
- openstacksdk
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함