错误在rails 4中的实时服务器上安装私有pub

时间:2015-07-15 12:01:15

标签: ruby-on-rails ruby ruby-on-rails-4 deployment private-pub

我正在为我的一个项目使用私人酒吧。它在localhost上运行正常,但是当我在实时服务器上部署它时会出现以下错误:

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网址上部署它。请建议。

1 个答案:

答案 0 :(得分:0)

localhost:9292表示它将绑定到1​​27.0.0.0,如果要从公共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;
}