Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nginx fallback
upstream blog_unicorn {
server unix:/home/vagrant/tmp/sockets/blog_unicorn.sock fail_timeout=0;
}
upstream redirector_unicorn {
server unix:/home/vagrant/tmp/sockets/redirector_unicorn.sock fail_timeout=0;
}
server {
server_name example.com;
listen 80; ## listen for ipv4; this line is default and implied
location / {
try_files $uri @blog_app;
}
location @blog_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_intercept_errors on;
recursive_error_pages on;
access_log /home/vagrant/redirector_logs/blog_access.log;
# pass to the upstream unicorn server mentioned above
proxy_pass http://blog_unicorn;
error_page 404 = @redirector_app;
}
location @redirector_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
#proxy_intercept_errors on;
recursive_error_pages on;
access_log /home/vagrant/redirector_logs/redirector.log;
proxy_pass http://redirector_unicorn;
error_page 404 =301 @homepage_temporary_redirect;
}
location @homepage_temporary_redirect {
access_log /home/vagrant/redirector_logs/redirector_404.log;
rewrite .* http://example.com/terminus redirect;
}
}
@agenteo

This comment has been minimized.

Copy link
Owner Author

@agenteo agenteo commented May 2, 2014

only blog_access.log and redirector.log are created at nginx startup, redirector_404 is not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment