在实际应用nginx的过程中,可能需要通过post请求静态页面;默认的nginx上,是决绝通过post方式访问静态页面;
在网上查看了一些解决办法,通过重定向error_page 来达到目的;在实际运用中,有时无法生效;
下面告诉一个终极的解决办法:
修改源码;

本文环境:
nginx: 1.2.2

tar zxvf nginx-1.2.2.tar.gz
cd ./nginx-1.2.2/src/http/modules/

vim ngx_http_static_module.c
找到如下行(大约在文件的第206行):

if (r->method & NGX_HTTP_POST) {
     return NGX_HTTP_NOT_ALLOWED;
}

将这段屏蔽掉;
/*
if (r->method & NGX_HTTP_POST) {
     return NGX_HTTP_NOT_ALLOWED;
}
*/


保存推出;

在使用之前编译nginx的参数,重新编译nginx版本,并进行替换(注意不要make install)即可。

相关文章:

  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-10-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-10-27
  • 2022-12-23
  • 2021-07-06
  • 2022-01-29
相关资源
相似解决方案