multiple rails apps - nginx, puma...

475 views
Skip to first unread message

Allen Maxwell

unread,
Jan 21, 2016, 12:19:15 AM1/21/16
to ur...@googlegroups.com
Hi All,

I’m configuring a digitalocean server (ubuntu) to host 2 different websites.  One is working just fine.  The other, from the nginx logs is attempting to route fine but the puma server isn’t running.

How do I configure puma to run both apps on a single server?  I’m really close but missing something critical.  Puma is only listed in the ps list for the single app and I don’t seem to be able to get it started for the other.  

Trying to start it manually results in:

$ start puma app=aamaxworks
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.155" (uid=1000 pid=6377 comm="start puma app=aamaxworks ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")


and no files are entered into the log, pids or sockets directories in the second app hierarchy.

the nginx log says:

2016/01/20 21:44:57 [crit] 4747#0: *419 connect() to unix:/home/deploy/sites/aamaxworks/shared/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 67.2.213.147, server: aamaxworks.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/deploy/sites/aamaxworks/shared/sockets/puma.sock:/500.html", host: "aamaxworks.com", referrer: "http://aamaxworks.com/"

 which makes sense because the server hasn’t stared and the requested file isn’t there…

I was able to (finally) manually start the second server with the following command:


and then both sites were accessible from the net.  

I have 2 files in my /etc/nginx/sites-available.  One for each application:

upstream app {
    # Path to Puma SOCK file, as defined previously
    server unix:/home/deploy/sites/mthost/shared/sockets/puma.sock fail_timeout=0;
}


server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name mthost.com www.mthost.com;

    root /home/deploy/sites/mthost;

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

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

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


and

upstream aamax_app {
    # Path to Puma SOCK file, as defined previously
    server unix:/home/deploy/sites/aamaxworks/shared/sockets/puma.sock fail_timeout=0;
}


server {
    listen 80;
    listen [::]:80;


    root /home/deploy/sites/aamaxworks;

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

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

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



I seem to be missing something (small) but I don’t know what… any help would be appreciated!

thanks in advance,

Max





Reply all
Reply to author
Forward
0 new messages