Environment: Nginx 1.0.10
Today, when debugging a site, found that the post way to request a static page, return http/1.1 405 method is not allowed state, unable to display the page normally.
Here to provide some of the next online solutions for your reference.
Method One
Copy code code as follows: Server
{
Listen 80;
server_name test.baidu.com;
Index index.html index.htm index.php;
root/www/test.baidu.com;
Error_page 405 = 200 @405;
Location @405
{
root/www/test.baidu.com;
}
Location ~. *.php?$
{
Include conf/fcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
}
}
Remark: Used in my environment cannot be solved.
Method Two
Edit Nginx Source Code
Vi/root/soft/nginx1.0.10/src/http/modules/ngx_http_static_module.c
Copy code code as follows: Comment out the original passage
/*
if (R->method & Ngx_http_post) {
return ngx_http_not_allowed;
}
*/
And then follow the original compilation parameters./configuer make does not use the makes install otherwise overwrites some of the original configuration files.
Perform
Copy code code as follows: CP $nginx _dir/sbin/nginx $nginx _dir/sbin/nginx.bak
CP./objs/nginx $nginx _dir/sbin/nginx
$nginx _dir/sbin/nginx-s Reload
Remark: Used in my environment cannot be solved.
Method Three
Copy code code as follows: Server
{
Listen 80;
server_name test.baidu.com;
Index index.html index.htm index.php;
root/www/test.baidu.com;
Location/
{
root/www/test.baidu.com;
Error_page 405 =200 http://$host $request_uri;
}
Location ~. *.php?$
{
Include conf/fcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
}
}
Remark: Used in my environment can be solved