在 rails 4 中在实时服务器上安装私人酒吧时出错
error installing private pub on live server in rails 4
我正在为我的一个项目使用私人酒吧。它在本地主机上运行良好,但是当我将它部署到实时服务器上时,出现以下错误:
Errno::ECONNREFUSED in CommentsController#new
Connection refused - connect(2) for "202.164.34.20" port 9292
这是我的 private_pub.yml 本地服务器文件内容:
development:
server: "http://localhost:9292/faye/faye"
secret_token: "secret"
test:
server: "http://localhost:9292/faye/faye"
secret_token: "secret"
production:
server: "http://example.com/faye/faye"
secret_token: "0378a6008f37cbd9c3390ce4069bb85f776d068f7b4885d6890f07066affde25"
signature_expiration: 3600 # one hour
对于其他服务器,这里是文件内容:
development:
server: "http://202.164.34.20:9292/faye/faye"
secret_token: "secret"
test:
server: "http://202.164.34.20:9292/faye/faye"
secret_token: "secret"
production:
server: "http://localhost:9292/faye/faye"
secret_token: "0378a6008f37cbd9c3390ce4069bb85f776d068f7b4885d6890f07066affde25"
signature_expiration: 3600 # one hour
现在我需要在 http://202.164.34.20:3001 url 上部署它。请建议。
localhost:9292 表示它将绑定到 127.0.0.0,如果你想从 public ip 访问,请确保绑定到你的外部 ip 或 0.0.0.0。
虽然我建议用 nginx/apache 代理它,这样用户就可以连接到端口 80
nginx 示例
server {
listen 80;
server_name faye.yourdomain.com;
access_log /var/log/nginx/faye.log;
location /faye {
proxy_pass http://127.0.0.1:9292;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_buffering off;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
}
}
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}
我正在为我的一个项目使用私人酒吧。它在本地主机上运行良好,但是当我将它部署到实时服务器上时,出现以下错误:
Errno::ECONNREFUSED in CommentsController#new
Connection refused - connect(2) for "202.164.34.20" port 9292
这是我的 private_pub.yml 本地服务器文件内容:
development:
server: "http://localhost:9292/faye/faye"
secret_token: "secret"
test:
server: "http://localhost:9292/faye/faye"
secret_token: "secret"
production:
server: "http://example.com/faye/faye"
secret_token: "0378a6008f37cbd9c3390ce4069bb85f776d068f7b4885d6890f07066affde25"
signature_expiration: 3600 # one hour
对于其他服务器,这里是文件内容:
development:
server: "http://202.164.34.20:9292/faye/faye"
secret_token: "secret"
test:
server: "http://202.164.34.20:9292/faye/faye"
secret_token: "secret"
production:
server: "http://localhost:9292/faye/faye"
secret_token: "0378a6008f37cbd9c3390ce4069bb85f776d068f7b4885d6890f07066affde25"
signature_expiration: 3600 # one hour
现在我需要在 http://202.164.34.20:3001 url 上部署它。请建议。
localhost:9292 表示它将绑定到 127.0.0.0,如果你想从 public ip 访问,请确保绑定到你的外部 ip 或 0.0.0.0。 虽然我建议用 nginx/apache 代理它,这样用户就可以连接到端口 80
nginx 示例
server {
listen 80;
server_name faye.yourdomain.com;
access_log /var/log/nginx/faye.log;
location /faye {
proxy_pass http://127.0.0.1:9292;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_buffering off;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
}
}
map $http_upgrade $connection_upgrade {
default Upgrade;
'' close;
}