Deploying a Rails app to a sub-URI with Passenger and Nginx?

若如初见. 提交于 2019-12-12 15:31:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!