Passenger + Rails app only works on port 3000

The passenger will launch on port 80, but only the home page (100% HTML) will appear. No other page will be allowed. And even a stranger, all traffic that cannot be resolved is redirected to HTTPS (which of course also cannot be resolved).

It works:

rvmsudo passenger start --daemonize

      

This does not work:

rvmsudo passenger start --daemonize --port 80

      

My config.ru is pretty standard too:

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

      

I am using Rails 4.2.0 and Ruby 2.2.2 with Passenger 5.0.7

Does anyone have any idea?

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;
    }
}

      

+3


source to share


1 answer


I think you need a different "setup" / configuration if you want to run the passenger behind nginx.

Nginx needs to listen on port 80 (specified in the server section of your nginx.conf) and redirect traffic to your app running under the hood of passengers (specified in nginx.conf to be on port 4000, but started manually on port 80) if I don't I am wrong.



Probably nginx is telling you that its unlucky in its log file /var/log/nginx.log I believe. You can confirm what is on port 80 by running netstat -tlpn

.

0


source







All Articles