0

I have a node application that accepts all routes starting at /. The Nginx / Passenger configuration for it is:

server {
    listen 8889;
    server_name localhost;

    location / {
        root /var/www/portal/public;
        passenger_enabled on;
        passenger_min_instances 1;
        passenger_app_env production;
    }

    location ~ /error/(.+) {
        alias /var/www/error-pages/$1;
    }
}

I want to move the application to run at /portal without changing anything about the node application. I've tried something like this without much luck:

server {
    listen 8889;
    server_name localhost;

    root /var/www/portal/public;

    location / {
        return 301 /client;
    }

    location /portal {
        passenger_base_uri /;
        passenger_app_root /var/www/portal;
        passenger_document_root /var/www/portal/public;
        passenger_min_instances 1;
        passenger_app_env production;
        passenger_enabled on;
    }

    location ~ /error/(.+) {
        alias /var/www/error-pages/$1;
    }
}

The problem is that the application continues to receive requests prefixed with /portal instead of /. I tried adding rewrite statements, but they do not seem to affect what Passenger passes into the application.

xmon
  • 1

1 Answers1

0

Change passenger_base_uri /; to passenger_base_uri /portal;.

From the official documentation :

8.2.2. passenger_base_uri

Used to specify that the given URI is a distinct application that should be served by Phusion Passenger.

Xavier Lucas
  • 13,095
  • 2
  • 44
  • 50
  • I tried that as well. No matter what I specify for `passenger_base_uri` the application always receives the request starting with `/client`. – xmon Oct 17 '14 at 22:34
  • @xmon Try `location ~ /portal(/.*)?$` form instead and add `alias /var/www/portal/public$1;` before passenger directives (let the base uri of my answer). – Xavier Lucas Oct 17 '14 at 22:55