【发布时间】:2013-03-29 20:38:59
【问题描述】:
我在 Debian 服务器 (ip 192.168.1.193) 中运行 rails 应用程序,乘客作为独立的
$ cd /home/hector/webapps/first
$ passenger start -a 127.0.0.1 -p 3000
我想在不同的子文件夹中为这个应用程序抛出带有反向代理的 Nginx:
http://192.168.1.193/first
我的 nginx.conf 服务器:
...
server {
listen 80;
server_name 127.0.0.1;
root /home/hector/webapps/first/public;
passenger_base_uri /first/;
location /first/ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
}
}
...
然后我运行 Nginx 服务器
$ /opt/nginx/sbin/nginx
使用此配置运行一个 Rails 应用程序似乎一切正常。
但是当我尝试添加我的第二个应用时
$ cd /home/hector/webapps/second
$ passenger start -a 127.0.0.1 -p 3001
使用这个 nginx.conf 文件:
...
server {
listen 80;
server_name 127.0.0.1;
root /home/hector/webapps/first/public;
passenger_base_uri /first/;
location /first/ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name 127.0.0.1;
root /home/hector/webapps/second/public;
passenger_base_uri /second/;
location /second/ {
proxy_pass http://127.0.0.1:3001;
proxy_set_header Host $host;
}
}
…
然后我重新加载 Nginx 服务器配置
$ /opt/nginx/sbin/nginx -s reload
nginx: [warn] conflicting server name "127.0.0.1" on 0.0.0.0:80, ignored
我收到警告,我无法访问第二个应用程序
http://192.168.1.193/second/
服务器为第二个应用返回 404,而第一个应用仍在运行。
【问题讨论】:
标签: ruby-on-rails nginx passenger