Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
nginx with unicorn on a subdirectory
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
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
Something went wrong with that request. Please try again.