Proxy to either Rails app or Node.js app depending on HTTP path w/ Nginx
Posted
by
Cirrostratus
on Server Fault
See other posts from Server Fault
or by Cirrostratus
Published on 2012-09-01T23:01:03Z
Indexed on
2012/09/02
3:39 UTC
Read the original article
Hit count: 509
On Ubuntu 11, I have Nginx correctly serving either CouchDB or Node.js depending on the path, but am unable to get Nginx to access a Rails app via it's port.
server {
rewrite ^/api(.*)$ $1 last;
listen 80;
server_name example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3005/;
}
location /ruby {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:9051/;
}
location /_utils {
proxy_pass http://127.0.0.1:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off; # buffering would break CouchDB's _changes feed
}
gzip on;
gzip_comp_level 9;
gzip_min_length 1400;
gzip_types text/plain text/css image/png image/gif image/jpeg application/x-javascript text/xml application/xml application/x
ml+rss text/javascript;
gzip_vary on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}
/ and /_utils are working bu /ruby gives me a 403 Forbidden
© Server Fault or respective owner