更新:目前,我在domain.com:3000上访问我的应用程序,但是我想访问domain.com来查看我的应用程序我在80处设置了nginx以在3000处代理我的rails应用程序.以下是配置upstream railsapp {server 127.0.0.1:3000;}server ...
更新:目前,我在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;
}
我指的是:
https://stackoverflow.com/a/5015178/1124639
它位于/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上运行独角兽.
所以我跑了乘客
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;
}
现在一切正常!
本文标题为:ruby-on-rails-如何配置Nginx代理到Rails应用程序?这样我就不必说domain.com:port
基础教程推荐
- swift 字符串String的使用方法 2023-07-05
- R语言数可视化Split violin plot小提琴图绘制方法 2022-12-10
- R语言-如何将科学计数法表示的数字转化为文本 2022-11-23
- UEFI开发基础HII代码示例 2023-07-07
- ruby-on-rails-使用Nginx的Rails的多阶段环境 2023-09-21
- R包ggtreeExtra绘制进化树 2022-12-14
- asm基础——汇编指令之in/out指令 2023-07-06
- R语言基于Keras的MLP神经网络及环境搭建 2022-12-10
- swift版webview加载网页进度条效果 2023-07-05
- Go web部署报错panic: listen tcp xxxxxxx:8090: bind: cannot assign requested address 2023-09-05