I have two apps: /foo and /bar. In each of those folders I'm starting up passenger. For foo:
passenger start -d -e production -p 4000And for bar:
passenger start -d -e production -p 4001I then have nginx configured like so:
server {
listen 80 default_server;
server_name www.server.com;
root /var/www/html;
location /foo/ {
proxy_pass http://0.0.0.0:4000/;
proxy_set_header Host $host;
}
location /bar/ {
proxy_pass http://0.0.0.0:4001/;
proxy_set_header Host $host;
}
}The apps are getting served up, but none of the links work. A link to the users#index action comes back as /users not /foo/users.
So then I followed the advanced configuration instructions for Passenger's nginx configuration and added passenger_base_uri = /foo; to my custom conf file and loaded it like so:
passenger start -d -e production -p 4000 --nginx-config-template nginx.conf.erb
Still no love, and I'm out of ideas. Has anyone done this before? It seems like a common way to deploy multiple apps in production.
More Thoughts (2015-06-05)
Adding passenger_base_uri = '/foo' to my nginx.conf.erb file hosts the application in TWO locations (which is odd to me, but whatever):
localhost:4000/localhost:4000/foo/The first doesn't have the correct resource links (i.e. it's just '/users') but has access to its assets.
The second has the correct resource links (e.g. '/foo/users') but doesn't have its assets (this is because it's looking for /foo/assets/* inside of its public folder, not just /assets/*). I believe that this is the way to go though, as I can change my proxy like this to get at the application:
location /foo/ {
proxy_pass http://0.0.0.0:4000/foo/;
proxy_set_header Host $host;
}Does anyone else have any thoughts though? If I do this, it'll mean I'll have to rake my assets intopublic/foo for it to work. Not the end of the world, but it still seems weird.