rewrite POST into GET?
Mark Slater
lists at humanesoftware.com
Fri Feb 15 04:13:57 MSK 2008
Wow Igor, that was fast! Thank you!
I downloaded the development version of nginx (I'd been using the
previous stable version 0.5.35), and applied the patch. Unfortunately,
when I started the new version of the server, the post_to_static
didn't change the 405 result sent back to facebook.
My configuration file looks like this:
http {
...
server {
listen 8080;
server_name localhost;
# set the max size for file uploads to 50 MB.
client_max_body_size 50M;
#charset koi8-r;
access_log logs/host.vhost.access.log main;
root /usr/local/webapps/listage/current/public;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
post_to_static on;
}
location / {
...
}
}
}
Do I have that right?
I tried it manually and got the same error:
mark$ telnet localhost 8080
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
POST / HTTP/1.0
Content-Length: 0
HTTP/1.1 405 Not Allowed
Server: nginx/0.6.26
Date: Fri, 15 Feb 2008 01:12:06 GMT
Content-Type: text/html
Content-Length: 173
Connection: close
<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/0.6.26</center>
</body>
</html>
Connection closed by foreign host.
Mark
On Feb 14, 2008, at 6:01 AM, Igor Sysoev wrote:
> On Thu, Feb 14, 2008 at 02:12:35AM -0800, Mark Slater wrote:
>
>> I'm working on a facebook application built using Rails. This is my
>> first time deploying a Rails site, and I'm setting up Capistrano to
>> do
>> the heavy lifting. I've got it creating a "down for maintenance" file
>> that I would like served to all facebook requests when I'm updating
>> things, but facebook always sends a POST request. This causes Nginx
>> to
>> respond with a 405 and report "client sent invalid method...";
>> obviously you can't really POST to a static page.
>>
>> Is there a way I can re-direct POST requests to GET requests or force
>> Nginx to return the static page regardless of the method used to
>> access it? My backup plan is to deploy a second app on a different
>> set
>> of ports that always returns the "down for maintenance" message....
>> but it seems silly to run one app to report you're upgrading another.
>
> The attached patch adds the "post_to_static" directive:
>
> location / {
> post_to_static on;
> }
>
> or
>
> server {
>
> if ( maintaince ) {
>
> ...
> break;
>
> post_to_static on;
> }
>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
> <post_to_static.txt>
More information about the nginx
mailing list