By matzavinosg
I have deployed a rails 4 application as follows: Nginx, as a reverse proxy server Unicorn, rails server Now I want to add a second server, Faye, for messaging alongside with unicorn. How I can configure nginx to accept and route requests to faye too?
My nginx default.conf file is:
upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/var/homes/HS/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
root /var/homes/HS/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
}
error_page 500 502 422 404 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
I know that I need to add a location /faye block to route the request. Something like:
location /faye {
proxy_pass http://127.0.0.1:9292;
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_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_set_header X-Forwarded-Proto https;
break;
}
Do I have to add the 127.0.0.1:9292; in my upstream block??? Is this enough? because my app give a connection time out.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You aren’t using the “app” upstream in location /faye so you shouldn’t add 127.0.0.1:9292; to the upstream block.
Your config looks proper. Is there anything listening on port 9292? Run
sudo netstat -plutn | grep 9292
and post the output.
Are you able to access the rails app directly? Try running:
curl http://localhost:9292/faye
Does that output what you expect browsing to /faye to output?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.