Skip to content

Instantly share code, notes, and snippets.

@robzolkos
Last active October 15, 2020 14:55
Show Gist options
  • Save robzolkos/e776f90b85fa0a131d6f4af41aeb4c2d to your computer and use it in GitHub Desktop.
Save robzolkos/e776f90b85fa0a131d6f4af41aeb4c2d to your computer and use it in GitHub Desktop.

Revisions

  1. robzolkos revised this gist Oct 15, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion curl.sh
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,4 @@ Date: Thu, 15 Oct 2020 14:33:10 GMT
    Content-Type: text/html
    Transfer-Encoding: chunked
    Connection: keep-alive
    Location: https://portal.example.com.au/portal
    Location: https://portal.example.com.au/cable
  2. robzolkos created this gist Oct 15, 2020.
    9 changes: 9 additions & 0 deletions curl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: portal.example.com.au" -H "Origin: https://portal.example.com.au" https://portal.example.com.au/cable

    HTTP/1.1 301 Moved Permanently
    Server: nginx/1.10.3 (Ubuntu)
    Date: Thu, 15 Oct 2020 14:33:10 GMT
    Content-Type: text/html
    Transfer-Encoding: chunked
    Connection: keep-alive
    Location: https://portal.example.com.au/portal
    47 changes: 47 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    upstream puma_portal {
    server unix:///home/example/apps/portal/shared/tmp/sockets/portal-puma.sock;
    }

    server {
    server_name portal.example.com.au;

    root /home/example/apps/portal/current/public;
    try_files $uri/index.html $uri.html $uri @puma_portal;

    location @puma_portal {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_read_timeout 300;
    proxy_pass http://puma_portal;
    }

    location /cable {
    proxy_pass http://puma_portal/portal;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    }

    location ~ ^/assets/ {
    gzip_static on;
    expires max;
    root /home/example/apps/portal/current/public;
    add_header Cache-Control public;
    add_header Last-Modified "";
    add_header ETag "";
    break;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/portal.example.com.au/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/portal.example.com.au/privkey.pem; # managed by Certbot
    }