Passenger + Rails app仅适用于端口3000

时间:2015-05-07 16:00:16

标签: ruby-on-rails ruby ruby-on-rails-4 passenger ports

Passenger将在端口80上启动,但只显示主页(100%HTML)。没有其他页面可以解决。甚至更奇怪的是,所有无法解决的流量都会转发到HTTPS(当然,也无法解决)。

这有效:

rvmsudo passenger start --daemonize

这不起作用:

rvmsudo passenger start --daemonize --port 80

我的config.ru也非常标准:

require ::File.expand_path('../config/environment',  __FILE__)
run Rails.application

我正在使用Rails 4.2.0和Ruby 2.2.2与Passenger 5.0.7

有人有什么想法吗?

nginx conf:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
    #passenger_ruby /home/ubuntu/.rvm/gems/ruby-2.2.2

app specific conf:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 80;
    server_name www.mydomain.com;

    # Tells Nginx to serve static assets from this directory.
    root /var/www/mydomain/public;

    location / {
        # Tells Nginx to forward all requests for www.foo.com
        # to the Passenger Standalone instance listening on port 4000.
        proxy_pass http://127.0.0.1:4000;

        # These are "magic" Nginx configuration options that
        # should be present in order to make the reverse proxying
        # work properly. Also contains some options that make WebSockets
        # work properly with Passenger Standalone. Please learn more at
        # http://nginx.org/en/docs/http/ngx_http_proxy_module.html
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_buffering off;
    }
}

1 个答案:

答案 0 :(得分:0)

如果您想在nginx后面驾驶乘客,我认为您需要一个不同的“设置”/配置。

Nginx应该侦听端口80(它在你的nginx.conf的服务器部分中指定),并将流量转发到你的应用程序运行的应用程序(在nginx.conf中指定为在端口4000上,但是手动启动)在80号港口,如果我没有误读。

可能nginx告诉你它在日志文件/var/log/nginx.log中不满意我相信。您可以通过执行netstat -tlpn来确认端口80上的内容。