Tags

Create a configuration file
vi /etc/nginx/conf.d/railsapp.conf and copy the content below

server {
        listen 80;
        server_name railsApp.com;
        rewrite ^ https://$host$request_uri? permanent;
}

server {
        server_name railsApp.com;

        listen 443 ssl;
        ssl_certificate /etc/nginx/ssl/nginx.crt;
        ssl_certificate_key /etc/nginx/ssl/nginx.key;

        gzip on;
        gzip_types      text/plain text/css application/javascript;
        gzip_min_length 1000;

        location / {
                proxy_pass http://localhost:3474;
                proxy_set_header Host $host;
                proxy_buffering off;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                # Adding support for WebSocket
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

        location /forum {
                proxy_pass http://localhost:4001;
                proxy_set_header Host $host;
                proxy_buffering off;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                # Adding support for WebSocket
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
        }
}

Advertisements