ruby - Nginx multiple hosts with Rails -
i have 2 apps in ruby on rails. + passenger. @ /var/www/app1
, /var/www/app2
. want use prefix in url determine 1 wanna hit.
so let's http://example.com/app1/users?order=id
goes app1 , http://example.com/app2/items
goes app2.
how can achieve this? tried solve using proxy did success.
update: here tries. not sure doing right.
location ~ ^/app1 { rewrite /app1(.*) /$1 break; proxy_pass http://127.0.0.1:9111; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_set_header x-forwarded-proto $scheme; proxy_redirect off; } location ~ ^/app2 { rewrite /app2(.*) /$1 break; proxy_pass http://localhost:9112; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_set_header x-forwarded-proto $scheme; } server { listen 9112; listen [::]:9112; error_log /usr/local/var/log/nginx/error.log; # self signed certs generated ssl-cert package passenger_enabled on; root /var/www/app2/public; rails_env development; } server { listen 9111; listen [::]:9111; error_log /usr/local/var/log/nginx/error.log; # self signed certs generated ssl-cert package passenger_enabled on; root /var/www/app1/public; rails_env development; }
Comments
Post a Comment