问题
I am already deployed my Rails app with Passenger and Nginx and it's working fine. Below is my servier configuration:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
Now I want to deploy a second app to a sub URI. Here the documentation is a little unclear.
Could anyone please suggest me what will be the next configuration?
Below is the configuration I am using for my second (Sinatra) application:
location /log {
root /var/www/logger/public;
passenger_base_uri /log;
passenger_enabled on;
}
I am getting "404 Not Found". Please suggest what I am missing here.
回答1:
Finally it's working!
nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
location /test {
root /var/www/demo;
passenger_base_uri /test;
passenger_enabled on;
}
Then:
ln -s /var/www/logger/public /var/www/demo/test
Thanks for all your help.
回答2:
Add ^~
before the sub-directory:
location /log
To:
location ^~ /log
来源:https://stackoverflow.com/questions/17162149/deploying-a-rails-app-to-a-sub-uri-with-passenger-and-nginx