1、比如 post请求静态html的
2、会返回nginx的405错误
3、那么如何设置有三种方法,1种重定向405错误码到200在nginx server{}里面添加以下内容,root为站点的根目录location ~ (.*\.json) { root /data/web/www; error_page 405 =200 $1; }nginx reload下即可
4、2种,转换静态文件接收的POST请求到GET方法去upstream static_backend { server localhost:80; } server { listen 80; ... error_page 405 =200 @405; location @405 { root /data/web/coolnull.com/www; proxy_method GET; proxy_pass http://static_backend; } }
5、3种源码文件位于/nginx源码目录/src/http/modules/ngx_http_static_module.c,找到如下代码:if (r->method & NGX_HTTP_POST) { return NGX_HTTP_NOT_ALLOWED; }整段注释掉,然后重新编译 make,不需要make install,把编译生成的nginx文件复制到sbin下的nginx文件,重启nginx即可。