Abhishek Aravindan
Abhishek Aravindan

Reputation: 1482

Deploying multiple rails application in a single digital ocean droplet using capistrano+nginx

I have a rails application running on a digital ocean server with IP xxx.xxx.xxx.xx .the deployed with Capistrano was easy now running with ease.Now I'm thinking to deploy another application to the same server using capistrano, After many research i'm not getting any proper solutions for my doubts or cant find any best tutorials for this.

What are the essential steps to look after before deploying the second application to the server?

Which nginx port the second application should listen to, 80 is default and the first application is already listening to that.?

How to access the second application after if deployed to the same droplet, now i can access the first application using the ip.?

Upvotes: 2

Views: 345

Answers (2)

Lyzard Kyng
Lyzard Kyng

Reputation: 1568

For testing purposes or limited-user-count applications you can have as many domains as you wish. You'd simply add to /etc/hosts (assuming you have Linux box)

NGINX.IP.ADDR.ESS domain-one.com
NGINX.IP.ADDR.ESS domain-two.com

Then use these server names in corresponding server blocks in your Nginx config file. In this case you can use the same port number. Other users of these applications should make the same changes on their boxes.

Moreover if such users are grouped within the same LAN you can configure fake zones on your DNS and use it instead of /etc/hosts.

Upvotes: 0

Krupa Suthar
Krupa Suthar

Reputation: 680

For each app, you need to make sure whatever server you are using is listening on a different socket.

After that, you have to add another server block in Nginx configurations like below,

upstream app_one {
    # Path to server1 SOCK file
}

upstream app_two {
    # Path to server2 SOCK file
}

server {
    listen 80;
    server_name IP;

    # Application root, as defined previously
    root /root/app_one/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_one;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
} 

server {
    listen 8080;
    server_name IP;

    # Application root, as defined previously
    root /root/app_two/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_two;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}  

Upvotes: 3

Related Questions