共计 1671 个字符,预计需要花费 5 分钟才能阅读完成。
最近维护一台 RedHat 5.4 X64 系统,环境是 Nginx,跑着一个论坛,需要向 HTML 页面提交 POST 数据,结果都被拦截下来了,显示错误:“nginx 405 Not Allowed”,是乎没有很好的解决办法,唯一能做的就是重新编译 Nginx 源码和编辑 conf 文件。
相关阅读 :
CentOS 6.2 实战部署 Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm
使用 Nginx 搭建 WEB 服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm
搭建基于 Linux6.3+Nginx1.2+PHP5+MySQL5.5 的 Web 服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm
CentOS 6.3 下 Nginx 性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm
CentOS 6.3 下配置 Nginx 加载 ngx_pagespeed 模块 http://www.linuxidc.com/Linux/2013-09/89657.htm
CentOS 6.4 安装配置 Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm
Nginx 搭建视频点播服务器(仿真专业流媒体软件)http://www.linuxidc.com/Linux/2012-08/69151.htm
需要修改 Nginx 中的 C 源码文件位于 /nginx 源码目录 /src/http/modules/ngx_http_static_module.c,找到如下代码:
if (r->method & NGX_HTTP_POST) {return NGX_HTTP_NOT_ALLOWED;}注释掉如下:
/*if (r->method & NGX_HTTP_POST) {return NGX_HTTP_NOT_ALLOWED;}*/ 然后再重新编译 make
复制 /nginx 源码目录 / objs 目录下的 nginx 至安装的 Nginx 目录下,重启 Nginx 生效。
对于 Nginx,可以修改 nginc.conf 配置文件,改变“405 错误”为“200 ok”,并配置 location 来解决,方法如下:
server {listen 80; server_name www.kiccleaf.com; index index.html index.htm index.php; root /data/kiccleaf; if ($host != 'www.kiccleaf.com' ) {rewrite ^/(.*)$ http://www.kiccleaf.com/$1 permanent;}location ~ .*\.(php|php5)?${fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fcgi.conf;}# 添加以下 405 代码 error_page 405 =200 @405; location @405 {root /data/kiccleaf; } } 也可以简单的编写成
server {listen 80; server_name www.kiccleaf.com; index index.html index.htm index.php; root /data/kiccleaf; if ($host != 'www.kiccleaf.com' ) {rewrite ^/(.*)$ http://www.kiccleaf.com/$1 permanent;}location ~ .*\.(php|php5)?${fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fcgi.conf;}# 添加以下 405 代码 error_page 405 =200 $uri; } Nginx 的详细介绍 :请点这里
Nginx 的下载地址 :请点这里






