From 2b85736f53e3d63a49f8d497b4a22d59f75d4c29 Mon Sep 17 00:00:00 2001 From: colben Date: Thu, 28 Nov 2024 13:51:02 +0800 Subject: [PATCH] update --- content/post/nginx.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/content/post/nginx.md b/content/post/nginx.md index 9e49931..8e19e41 100644 --- a/content/post/nginx.md +++ b/content/post/nginx.md @@ -1,7 +1,7 @@ --- title: "Nginx 笔记" date: 2019-10-30T11:47:55+08:00 -lastmod: 2024-11-25T22:23:00+08:00 +lastmod: 2024-11-28T13:22:00+08:00 tags: ["nginx", "https", "ssl", "反向代理"] categories: ["web"] --- @@ -87,6 +87,38 @@ categories: ["web"] try_files _ @app; ``` +## error_page +- 语法 + ``` + error_page code ... [=[response]] uri; + code 只能是 4xx 或 5xx + # uri 可以包含变量,内部重定向请求,方法是 GET + ``` + +- 位置: http, server, location, if in location +- 5xx 重定向到 /fk.html + ``` + error_page 500 502 503 504 /fk.html; + ``` + +- 指定响应码 + ``` + error_page 404 =200 /fk.html; + # 404 重定向到 /fk.html,返回 200 + + error_page 401 = /proxy/api; + # 401 重定向到一个反代 location,返回反代接口的响应码 + ``` + +- url 重定向 + ``` + error_page 403 http://another-site/a/b/c; + # 403 重定向到 302,返回 url + + error_page 403 =301 http://another-site/a/b/c; + # 403 重定向到 301,返回 url + ``` + ## 客户端访问控制 - deny all 拒绝全部访问 - deny 192.168.1.0/24 拒绝指定网段 @@ -100,7 +132,6 @@ categories: ["web"] location / { root /var/www/html/; index index.html index.htm; - try_files $uri $uri/ /index.html =404; } ```