Ruby Rails 应用无法访问 Nginx
Ruby on Rails app with Nginx unreachable
我正在远程服务器上的 Rails 网站上部署我的 Ruby。
我把我的代码放在 /var/www/[websitename]
/opt/nginx/conf/nginx.conf
如下:
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/tamer/.rvm/gems/ruby-2.5.0@meraki/gems/passenger-5.2.0;
passenger_ruby /home/tamer/.rvm/gems/ruby-2.5.0@meraki/wrappers/ruby;
passenger_app_env development;
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name http://[my external ip];
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/[my directory]/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;
}
- 那我运行
rails s -b 127.0.0.1 -p 3000
代码在我的终端中运行完美。
但是,浏览器给我 "This site can’t be reached".
我得到与 passenger start -a 127.0.0.1 -p 3000
相同的结果
我该如何解决这个问题
它在 运行 iptables -F
并重新启动我的 rails 应用程序后工作。
注意
您正在连接到您的乘客实例 localhost:3000
您应该可以通过 http://localhost IE 默认端口 80 进行连接,我想这就是您想要的。
听80; <- > proxy_pass http://127.0.0.1:3000;
我正在远程服务器上的 Rails 网站上部署我的 Ruby。
我把我的代码放在 /var/www/[websitename]
/opt/nginx/conf/nginx.conf
如下:
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/tamer/.rvm/gems/ruby-2.5.0@meraki/gems/passenger-5.2.0;
passenger_ruby /home/tamer/.rvm/gems/ruby-2.5.0@meraki/wrappers/ruby;
passenger_app_env development;
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name http://[my external ip];
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/[my directory]/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;
}
- 那我运行
rails s -b 127.0.0.1 -p 3000
代码在我的终端中运行完美。 但是,浏览器给我 "This site can’t be reached".
我得到与 passenger start -a 127.0.0.1 -p 3000
我该如何解决这个问题
它在 运行 iptables -F
并重新启动我的 rails 应用程序后工作。
注意 您正在连接到您的乘客实例 localhost:3000 您应该可以通过 http://localhost IE 默认端口 80 进行连接,我想这就是您想要的。
听80; <- > proxy_pass http://127.0.0.1:3000;