gpt4 book ai didi

ruby-on-rails - rails nginx puma 在/etc/nginx/sites-enabled 中复制上游 "puma"

转载 作者:行者123 更新时间:2023-12-04 06:18:45 28 4
gpt4 key购买 nike

我已经为本教程设置了我的服务器 ( https://coderwall.com/p/ttrhow/deploying-rails-app-using-nginx-puma-and-capistrano-3 )

当我使用一个项目时,一切正常,但是当我将另一个项目添加到此 VPS 时,出现错误[emerg] 20737#0: duplicate upstream "puma" in /etc/nginx/sites-enabled/vsejalreg:1
我的 nginx 配置

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;
}


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;
}

当我一一添加nginx配置时 - 一切正常!

如何修复这个包或 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;
}

否则你会遇到这样的错误 - nginx: [emerg] host not found in upstream "puma" in /etc/nginx/sites-enabled/furnitureapp:25
因此,如果您将上游重命名为
upstream puma_register

您还需要将您的 proxy_pass 重命名为
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
}

关于ruby-on-rails - rails nginx puma 在/etc/nginx/sites-enabled 中复制上游 "puma",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29169098/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com