我有一个使用Thin运行的Rails应用程序,我希望Nginx充当反向代理,将给定位置下的所有请求传递给Thin服务器。
从我读过的所有内容(这已经是相当多的了),似乎最stream行的解决scheme是有以下站点configuration文件:
upstream thin { server 127.0.0.1:3000; } server { ... location /thin { proxy_pass http://thin; } }
但是,在我的情况下,这个设置的问题是/thin部分传递给Thin。 我在其他地方读过,因为这个原因,最好使用一个命名的位置:
server { ... location @thin { proxy_pass http://thin; } }
但是,当我使用这个configuration时,检查/var/log/nginx/error.log我看到请求没有传递到瘦服务器(服务器位于IP地址192.168.1.15和客户端是192.168.1.105) :
2013/04/11 12:55:58 [error] 17988#0: *1 open() "/var/www/thin" failed (2: No such file or directory), client: 192.168.1.105, server: , request: "GET /thin HTTP/1.1", host: "192.168.1.15"
我究竟做错了什么? 如何处理指定的位置以及它们的用途是什么?
在正常处理请求期间不使用命名位置,它们仅用于处理内部redirect的请求(例如,error_page,try_files)。
尝试使用
server { ... location /thin { proxy_pass http://thin/; } }
注意最后的斜线。