在 Ubuntu 11 上,我让 Nginx 根据路径正确地提供 CouchDB 或 Node.js 服务,但无法让 Nginx 通过其端口访问 Rails 应用程序。
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)";
}
/ 和 /_utils 正在工作,但是 /ruby 给了我一个403 Forbidden