I would like to run multiple rails apps with just using different location blocks. Different unicorn workers are started and configured, they are working just fine.
Every app is under the same folder: /var/www/<app>
, so I configured nginx like this:
root /var/www;
location /app1/ {
root /var/www/app1/public;
try_files $uri/index.html $uri.html $uri @app1;
}
location /app2/ {
root /var/www/app2/public;
try_files $uri/index.html $uri.html $uri @app2;
}
My issue is that w/ this ruleset a request (like mydomain/app1/check) comes into my app1 like this: Started GET "/app1/check" for ...
I would like to have just Started GET "/check" for ...
What should i change on my config?
If you don't want to change your upstream parameters (whatever you are doing in your
@app
locations), a simplerewrite
can help you:The
break
parameter torewrite
will cause nginx to rewrite the URI without actually redirecting or rerouting the request.Don't forget to add the prefix
/app1/
to yourtry_files
names, because$uri
will already be rewritten at the timetry_files
runs.How did you setup your assets path in this case?
My assets path is
but the correct path is:
My config is mostly the same as the one above.
I do this with nginx, uwsgi, and django/wsgi - the key is:
I host the apps as "names"; i.e., /tiny/foobar/, but the app sees the path as /foobar/ because of the SCRIPT_NAME change above. modifier1 is peculiar to WSGI (IIRC), so may not apply to you setup.