Solution to not allowed of http/1.1 405 method in Nginx

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.