Here's my puma configuration:
path = Dir.pwd + "/tmp/puma/"
threads 0,20
environment "production"
daemonize true
drain_on_shutdown true
# _load_from path
bind "unix://" + path + "socket/puma.sock"
pidfile path + "pid/puma.pid"
state_path path + "pid/puma.state"
and here's my nginx configuration:
upstream rails_app {
server /srv/rails/project/tmp/puma/socket/puma.sock;
}
server {
# server_name domain.tld www.domain.tld;
root /srv/rails/project/public;
try_files $uri/index.html $uri @rails_app;
location @rails_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://rails_app;
}
error_page 500 504 /500.html;
error_page 502 /502.html;
error_page 503 /503.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
And yet, when I restart nginx:
sudo service nginx restart
I get this:
Starting nginx: nginx: [emerg] invalid host in upstream "/srv/rails/project/tmp/puma/socket/puma.sock" in /etc/nginx/sites-enabled/default:2
nginx: configuration file /etc/nginx/nginx.conf test failed
I can get some more clues here:
tail -f /var/log/nginx/error.log
2014/04/30 09:07:33 [error] 7517#0: *1 directory index of "/srv/rails/project/" is forbidden, client: <ip address>, server: , request: "GET / HTTP/1.1", host: <ip address>
2014/04/30 09:35:55 [emerg] 8245#0: invalid host in upstream "/srv/rails/project/tmp/puma/socket/puma.sock" in /etc/nginx/sites-enabled/default:2
But it doesn't mean much to me I'm afraid!
Also, I'm storing my pid and my sock inside the projects root folder. Is there a dedicated place on an ubuntu server that they should go?
Your configuration is not correct. The right upstream path would be:
server unix:///srv/rails/project/tmp/puma/socket/puma.sock;
The unix:// means it's a socket. You could also use tcp://, for example, and point it to a port, like tcp://127.0.0.1:8080
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With