405 (Not Allowed) on POST request
Usually these error messaged are caused by the limitation that Nginx can't serve static content on POST
request. This issue is discussed and workarounds suggested on InValidLogic.com's article Serving Static Content Via POST From Nginx: in that case you could replace the error message with error_page 405 =200 $uri;
or create a proxy for static content, converting POST
request to GET
.
However, in this case your /formcheck
is actually a PHP script instead of static content, thus POST
requests should be allowed by Nginx and there is POST
data to be received, so converting to GET
isn't an option, either.
It seems you have two location
sections:
location / {
if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
root home/$2/public_html;
access_log logs/$2-access.log main;
}
}
location ~ \.php$ {
if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
root home/$2/public_html;
access_log logs/$2-access.log main;
}
if (!-e $document_root$document_uri){return 404;}
fastcgi_pass localhost:9071;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
As you can see, only locations ending with .php
are handled with fastcgi, while everything else including /formcheck
falls into location /
serving only static content, causing the 405
error.