Skip to main content

How to manage upstream with ssl?

Rails • Asked by naveen kumar

I am trying to deploy with nginx puma using upstream so
should i use ssl connection with my upstream https://my_app

upstream my_app {
server; # or the port you configured in puma configuration file

server {
listen 443 ssl ;

    ssl_certificate /etc/ssl/certs/2020.crt;
    ssl_certificate_key /etc/ssl/private/2020.key;
    #ssl_dhparam /etc/ssl/certs/dhparam.pem;

    server_name ;

    root /var/www/vhosts/;

            location / {
                    proxy_pass http://my_app; # match the name of upstream directive which is defined above
                    proxy_set_header Host $host;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            location ~* ^/assets/ {
                    # Per RFC2616 - 1 year maximum expiry
                    expires 1y;
                    add_header Cache-Control public;

                    # Some browsers still send conditional-GET requests if there's a
                    # Last-Modified header or an ETag header even if they haven't
                     # reached the expiry date sent in the Expires header.
                    add_header Last-Modified "";
                    add_header ETag "";
           location /cable {
                    proxy_pass http://my_app;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.