Created
October 8, 2010 13:12
-
-
Save lorn/616762 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 manager { | |
# fail_timeout=0 means we always retry an upstream even if it failed | |
# to return a good HTTP response (in case the Unicorn master nukes a | |
# single worker for timing out). | |
server unix:/opt/x.com/manager/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name www.x.com.com _ default; | |
keepalive_timeout 5; | |
error_log /var/log/nginx/manager.log debug; | |
root /opt/x.com/wordpress/current; | |
set_real_ip_from xxx.xxx.xxx.xxx; | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location /rails { | |
internal; | |
root /opt/x.com/manager/current/public; | |
# Remove the '/rails' part from the url the look in here. | |
rewrite ^/rails(.*)$ $1 break; | |
# Only expose ipan data to the ipan, not anyone else | |
location ~ /ipan_data$ { | |
allow xxx.xxx.xxx.xxx; | |
deny all; | |
} | |
# Don't let hits to public/migrate actually be served 'externally' | |
location = /rails/migrate.html { | |
internal; | |
} | |
try_files $uri /migrate.html @rails; | |
} | |
# Static files from the rails app. | |
if (-f /opt/x.com/manager/current/public$uri ) { | |
rewrite ^ /rails$uri last; | |
} | |
# Urls starting with these are served from the rails app. | |
location /users { rewrite ^ /rails$uri last; } | |
location /products { rewrite ^ /rails$uri last; } | |
location /sales { rewrite ^ /rails$uri last; } | |
location /login { rewrite ^ /rails$uri last; } | |
location /logout { rewrite ^ /rails$uri last; } | |
# Else try wordpress (including it's static files) | |
index index.php; | |
try_files $uri /wordpress$uri$is_args$args; | |
location @rails { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://manager; | |
} | |
location ~^(/wordpress)(/.*)$ { | |
set $path $2; | |
internal; | |
root /opt/x.com/wordpress/shared/wordpress/; | |
# This is for static files. The $1 is becaus 'the "alias" directive must | |
# use captures inside location given by regular expression' | |
#alias /opt/x.com/wordpress/shared/$1/; | |
try_files $path $path/ /wordpress/index.php?q=$path&$args; | |
location ~ (\.php)$ { | |
# And this is so php doesn't see the wordpress dir | |
rewrite ^/wordpress(.*)$ $1 break; | |
root /opt/x.com/wordpress/shared/wordpress/; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_index index.php; | |
fastcgi_pass unix:/tmp/php-fastcgi.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment