This commit is contained in:
colben 2024-11-28 13:51:02 +08:00
parent b26079b313
commit 2b85736f53

View File

@ -1,7 +1,7 @@
--- ---
title: "Nginx 笔记" title: "Nginx 笔记"
date: 2019-10-30T11:47:55+08:00 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", "反向代理"] tags: ["nginx", "https", "ssl", "反向代理"]
categories: ["web"] categories: ["web"]
--- ---
@ -87,6 +87,38 @@ categories: ["web"]
try_files _ @app; 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 all 拒绝全部访问
- deny 192.168.1.0/24 拒绝指定网段 - deny 192.168.1.0/24 拒绝指定网段
@ -100,7 +132,6 @@ categories: ["web"]
location / { location / {
root /var/www/html/; root /var/www/html/;
index index.html index.htm; index index.html index.htm;
try_files $uri $uri/ /index.html =404;
} }
``` ```