faye private_pub rails ubuntu connection refused
<p>So I tried to set up a rails app using Bryan Bate's private_pub gem (a wrapper for the faye gem) to create chat channels. It works great on my local machine in dev mode. </p>

<p>I'm also booting up the private_pub server on port 8080 at the same time my rails app starts by including a initializer file with the lines:</p>

<pre><code>Thread.new do
  system("rackup private_pub.ru -s thin -E production -p 8080")
end
</code></pre>

<p>however, after deploying to aws ec2 ubuntu instance with the nginx webserver and puma app sever, the chrome console keeps showing this every 2 seconds, and the real time chat features don't work.</p>

<pre><code>GET http://localhost:8080/faye.js net::ERR_CONNECTION_REFUSED
</code></pre>

<p>If I open port 8080 in my aws security group, I can see the big chunk of javascript code in faye.js using curl from localhost:8080/faye.js when I ssh into the instance. I can also access it from my browser if I go to <a href="http://my.apps.public.ip:8080/faye.js" rel="nofollow">http://my.apps.public.ip:8080/faye.js</a>. I can't access it if I remove 8080 from the security group, so I don't think this is an firewall problem. </p>

<p>Also, if I change the address from localhost to 0.0.0.0 or the public ip for my ec2 instance, the chrome console error is gone, but the real time chat is still not working.</p>

<p>I suspect I might have to do more configuration to nginx because all I have done so far to configure the nginx server is in /etc/nginx/sites-available/default, I have:</p>

<pre><code>upstream app {
  server unix:/home/deploy/myappname/shared/tmp/sockets/puma.sock fail_timeout=0;
}

server {
  listen 80;
  server_name localhost;

  root /home/deploy/myappname/public;

  try_files $uri/index.html $uri @app;

  location / {
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection '';
    proxy_pass http://app;
  }

  location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}
</code></pre>

<p>But maybe this has nothing to do with nginx either, I'm pretty lost. Has anyone experienced this or could suggest an alternative solution? I could post any additional config files here if needed.</p>