-
-
Save ctcherry/21453be0610ded1cfc36 to your computer and use it in GitHub Desktop.
nginx with unicorn on a subdirectory
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
Unicorn conf can be your normal stuff, set it to the same port as "upstream app_unicorn" | |
The trick is now to start it with the env variable: RAILS_RELATIVE_URL_ROOT=/sub | |
So the full command I use is: | |
RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/sub bundle exec unicorn -c unicorn_config.rb -D |
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 app_unicorn { | |
server 127.0.0.1:8001 fail_timeout=0; | |
} | |
server { | |
root /someapp/path/current/public; | |
# Handle assets and direct requests to the right place | |
location ~* /sub(/.*)? { | |
try_files $1/index.html $1.html $1 @app_proxy; | |
} | |
location @app_proxy { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://app_unicorn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment