I've set up my server for this tutorial (https://coderwall.com/p/ttrhow/deploying-rails-app-using-nginx-puma-and-capistrano-3)
When I used one project, all works, but when I added another project to this VPS, I have error
[emerg] 20737#0: duplicate upstream "puma" in /etc/nginx/sites-enabled/vsejalreg:1
My nginx's configure
upstream puma {
server unix:///home/deployer/apps/vsejalreg/shared/tmp/sockets/vsejalreg-puma.sock;
}
server {
listen 80;
server_name wjreg.rubyserv.ru www.wjreg.rubyserv.ru;
root /home/deployer/apps/vsejalreg/current/public;
access_log /home/deployer/apps/vsejalreg/current/log/nginx.access.log;
error_log /home/deployer/apps/vsejalreg/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
And
upstream puma {
server unix:///home/deployer/apps/register/shared/tmp/sockets/register-puma.sock;
}
server {
listen 80;
server_name ws.rubyserv.ru www.ws.rubyserv.ru;
root /home/deployer/apps/register/current/public;
access_log /home/deployer/apps/register/current/log/nginx.access.log;
error_log /home/deployer/apps/register/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
When I add nginx configure one by one - all work!
How fix this bag or puma not working with many project?
Thx!
Please note, that you need to change this part aswell:
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
Else you will run into errors such as this - nginx: [emerg] host not found in upstream "puma" in /etc/nginx/sites-enabled/furnitureapp:25
So, if you rename your upstream to
upstream puma_register
You need to rename your proxy_pass as well to
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma_register; <------ Change here
}
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