常用配置

Nginx 的常用配置 #

Post 返回静态内容 #

因为 Nginx 有着无法根据 POST 请求提供静态内容的限制,所以可以利用这个限制将 405 错误信息替换成静态内容来达到目的。主要配置

error_page 405 =200 $uri

参考资料 #

POST 请求出现 405(不允许)
不允许 POST 请求 - 405 Not Allowed - nginx,即使包含标头
Serving Static Content Via POST From Nginx

接收 Post 请求参数 #

在文件 nginx.confhttp 的配置里添加下面的内容
http{ ... log_format post_tracking '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$request_body" '; ... }

参考资料 #

nginx 配置接收 post 请求参数