Skip to content

Instantly share code, notes, and snippets.

Created July 17, 2009 22:42
Show Gist options
  • Save anonymous/149321 to your computer and use it in GitHub Desktop.
Save anonymous/149321 to your computer and use it in GitHub Desktop.
user leo;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
upstream mongrel {
server 127.0.0.1:4000;
}
server {
listen 8888;
server_name *.twifeedback.com twifeedback.com;
client_max_body_size 50M;
root /web/merb/twifeedback/public;
access_log /web/merb/twifeedback/log/nginx.access.log main;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
ssi on;
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;
if (-f $request_filename) {
break;
}
rewrite (.*) /$http_host$1;
if (-f $request_filename) {
break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
# Use other cluster name here if you are running multiple
# virtual hosts.
proxy_pass http://mongrel;
break;
}
}
}
server {
listen 80;
server_name _;
client_max_body_size 50M;
root /web/merb/cheddr/public;
access_log /web/merb/cheddr/log/nginx.access.log main;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
ssi on;
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;
# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
break;
}
rewrite (.*) /$http_host$1;
# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
break;
}
# check for index.html for directory index
# if its there on the filesystem then rewite
# 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;
}
# this is the meat of the rails page caching config
# it adds .html to the end of the url and then checks
# the filesystem for that file. If it exists, then we
# rewite the url to have explicit .html on the end
# and then send it on its way to the next config rule.
# if there is no file on the fs then it sets all the
# necessary headers and proxies to our upstream mongrels
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
# Use other cluster name here if you are running multiple
# virtual hosts.
proxy_pass http://mongrel;
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment