Example 1: Send a POST request to an HTML static page on the Apache server with the Curl command under Linux
Copy Code code as follows:
[Root@localhost ~]# curl-d 11=1 http://www.jb51.net/index.html
<! DOCTYPE HTML PUBLIC "-//ietf//dtd HTML 2.0//en" >
<HTML>
<HEAD>
<title>405 Method Not allowed</title>
</HEAD>
<BODY>
The requested method POST is isn't allowed for the url/index.html.<p>
<HR>
<address>apache/1.3.37 Server at Www.jb51.net Port 80</address>
</BODY>
</HTML>
Example 2: Using the Curl command under Linux to send post requests to the HTML static page on the Nginx server
Copy Code code as follows:
[Root@localhost ~]# curl-d 11=1 http://www.jb51.net/index.htm
<body bgcolor= "White" >
<center></body>
However, in some applications, it is necessary to enable static files to respond to post requests.
For Nginx, you can modify the nginc.conf configuration file, change the "405 error" to "OK" and configure the location to resolve the following methods:
Copy Code code as follows:
Server
{
Listen 80;
server_name www.jb51.net;
Index index.html index.htm index.php;
Root/opt/htdocs;
if (-D $request _filename)
{
Rewrite ^/(. *) ([^/]) $ http://$host/$1$2/permanent;
}
Error_page 405 = 200 @405;
Location @405
{
Root/opt/htdocs;
}
Location ~. *\.php?$
{
Include conf/fcgi.conf;
Fastcgi_pass 127.0.0.1:10080;
Fastcgi_index index.php;
}
}
Of course, you can modify the Nginx source code to solve
Modify the source code, recompile the installation Nginx
Edit Nginx Source Code
Copy Code code as follows:
[Root@localhost ~]# Vim src/http/modules/ngx_http_static_module.c
Modify: Find the following comment out
Copy Code code as follows:
/*
if (R->method & Ngx_http_post)
{
return ngx_http_not_allowed;
}
*/
Then, according to the original compilation parameters, recompile installation nginx, you can