Created
January 15, 2009 12:24
-
-
Save pointcom/47389 to your computer and use it in GitHub Desktop.
Serving rails page caches to a facebook POST request with nginx (error)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream mongrel { server 127.0.0.1:4010; } | |
server { | |
listen 4000; | |
# General | |
server_name localhost; | |
root /path/to/project/public; | |
# Set the max size for file uploads to 50Mb | |
client_max_body_size 50M; | |
location / { | |
# needed to forward user's IP address to rails | |
proxy_set_header X-Real-IP $remote_addr; | |
# needed for HTTPS | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect false; | |
proxy_max_temp_file_size 0; | |
# Static file | |
if (-f $request_filename) { | |
break; | |
} | |
# check for index.html for directory index | |
# if its there on the filesystem then rewrite | |
# the url to add /index.html to the end of it | |
# and then break to send it to the next config rules. | |
if (-f $request_filename/index.html) { | |
rewrite (.*) $1/index.html break; | |
} | |
# Cache | |
if (-f $request_filename.html) { | |
rewrite (.*) $1.html break; | |
} | |
# Merb | |
if (!-f $request_filename) { | |
proxy_pass http://mongrel; | |
break; | |
} | |
# this rewrites all the requests to the maintenance.html | |
# page if it exists in the doc root. This is for capistrano's | |
# disable web task | |
if (-f $document_root/system/maintenance.html) { | |
rewrite ^(.*)$ /system/maintenance.html last; | |
break; | |
} | |
} | |
error_page 405 =200 @405; | |
location @405 { | |
index index.html index.htm; | |
# needed to forward user's IP address to rails | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect false; | |
proxy_max_temp_file_size 0; | |
proxy_next_upstream error; | |
if (-f $request_filename) { | |
break; | |
} | |
if (-f $request_filename.html) { | |
rewrite (.*) $1.html break; | |
} | |
if (!-f $request_filename) { | |
proxy_pass http://mongrel; | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -X GET http://localhost:4000/page.html | |
Hello World | |
$ curl -X POST http://localhost:4000/page.html -d "" | |
<html> | |
<head><title>405 Not Allowed</title></head> | |
<body bgcolor="white"> | |
<center><h1>405 Not Allowed</h1></center> | |
<hr><center>nginx/0.6.34</center> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment