1

I am currently running a simple Meteor.js application on a server using Phusion Passenger + Nginx.

What I would like to do is to configure it so that I have one main app on www.example.com and additional apps on www.example.com/app1, www.example.com/app2 and so on. How can I achieve this configuration using the above-mentioned tools? I know how to do this using only nginx, but it seems like additional configuration for Passenger is required.

My current nginx configuration is as follows:

server {
  listen 80;
  server_name example.com;

  # Tell Nginx and Passenger where your app's 'public' directory is
  root /var/www/app1/bundle/public;

  passenger_friendly_error_pages on;

  # Turn on Passenger
  passenger_enabled on;
  # Tell Passenger that your app is a Meteor app
  passenger_app_type node;
  passenger_startup_file main.js;

  # Tell your app where MongoDB is
  passenger_env_var MONGO_URL mongodb://127.0.0.1:27017/app1;
  # Tell your app what its root URL is
  passenger_env_var ROOT_URL http://www.example.com/app1;
}

This serves the application on www.example.com/, but I would like to move it to www.example.com/app1/.

bjrnt
  • 111
  • 3

1 Answers1

0

I try to do the same thing. It works but I still do have a small problem with my assets (I use rails)

In your server block you want to add a location block.

Here is how I do it:

location ~ ^/app1(/.*|$) {
    root /srv/www/app1/current/public;

    passenger_base_uri /app1;
    passenger_app_root /srv/www/app1/current;
    passenger_document_root /srv/www/app1/current/public;
    passenger_enabled on;
}

And now example.com/app1 serves your app.

Add as many location block as you want on the same pattern for more apps.

gdurelle
  • 111
  • 5
  • Root should be '/srv/www'. Web server appends app1. Regex in app1 is disgarded here. On difference between `alias` and `root`, see https://stackoverflow.com/q/10631933/1086346 – pauljohn32 Feb 03 '20 at 05:39