更新:目前,我在domain.com:3000上访问我的应用程序,但是我想访问domain.com来查看我的应用程序
我在80处设置了Nginx以在3000处代理我的rails应用程序.以下是配置
upstream railsapp {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name APP;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/APP/current/public;
index index.html index.htm;
# Static assets are served from the mentioned root directory
location / {
root /var/www/APP/current;
index index.html index.htm;
proxy_pass http://railsapp/;
proxy_redirect off;
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_set_header X-Real-Port $server_port;
# proxy_set_header X-Real-Scheme $scheme;
proxy_set_header X-Nginx-Proxy true;
}
# Turn on Passenger
passenger_enabled on;
passenger_ruby /usr/local/rvm/gems/ruby-2.1.3/wrappers/ruby;
}
我指的是:
@L_403_0@
它位于/etc/Nginx/sites-enabled/APP.conf中,并包含在/etc/Nginx/Nginx.conf中,如下所示,位于http {…}中
include /etc/Nginx/sites-enabled/*;
但是我的APP.com仍然显示“欢迎使用Ubuntu上的Nginx!” APP.com:3000显示了我的应用.我究竟做错了什么?
我正在使用什么:
Ubuntu 14.04 EC2实例
Nginx 1.8.0
麒麟服务器3000
最佳答案
我试图运行独角兽,以便可以将我的应用程序分叉到多个实例.我猜这里的问题是,我将passenger_enabled设置为on,并且实际上是在3000上运行独角兽.
原文链接:https://www.f2er.com/nginx/532446.html所以我跑了乘客
passenger start -a 127.0.0.1 -p 3000 -d -e production
和我的Nginx conf这样,
server {
listen 80;
server_name www.APPNAME.com;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/APPNAME/current/public;
index index.html index.htm;
# Static assets are served from the mentioned root directory
location / {
# root /var/www/APPNAME/current;
# index index.html index.htm;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
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_set_header X-Real-Port $server_port;
# proxy_set_header X-Real-Scheme $scheme;
proxy_set_header X-Nginx-Proxy true;
}
# Turn on Passenger
passenger_enabled on;
passenger_ruby /usr/local/rvm/gems/ruby-2.1.3/wrappers/ruby;
}
现在一切正常!