G
G
g_s_e2017-05-02 22:47:41
Nginx
g_s_e, 2017-05-02 22:47:41

How to set up multiple Rails applications on one nginx?

Good day, I had a need to set up several Rails applications on one digitalocean droplet. Applications include API for mobile applications + admin panel, without domains, access from the world via "....ip/admin", "...ip/api/...." the applications themselves are in the same directory:

/home/user_name/apps/app_1
/home/user_name/apps/app_2

With the location's setting in /etc/nginx/sites-available/default it looks something like this:
location /app-name_1/ {
    passenger_enabled on;
    rails_env   development;
    root         /home/username/apps/app2_name/current/public;
  }
location /app-name_2/ {
    passenger_enabled on;
    rails_env   development;
    root         /home/username/apps/app2_name/current/public;
  }

The essence of the question is how to set up assets for each of the projects? For one application, this will look like this:
location ~ ^/(assets|images|fonts)/(.*)$ {
        alias /home/user_name/apps/app_name/current/public/$1/$2;
        gzip on;
        expires max;
        add_header Cache-Control public;
    }

In this case, each app tries to find css/js files at ip-adress/assets/...
How can I specify a custom directory (assets|images|fonts) for each project? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question