Skip to content

Instantly share code, notes, and snippets.

@evansmwendwa
Created February 29, 2020 14:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansmwendwa/22dc49bfe110ccd2aacc8280dbca227a to your computer and use it in GitHub Desktop.
Save evansmwendwa/22dc49bfe110ccd2aacc8280dbca227a to your computer and use it in GitHub Desktop.

Setting up Localhost Nginx Reverse Proxy to react app

This helps you develop react apps through a sub domain secured by ssl through nginx without much hassle. Current config from Laragon on Windows

server {
    listen 80;
    listen 443 ssl;
    server_name app.sparkwave.test;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://localhost:3000;

        # the following two timeout rules fix CRA WDS disconnects after 60s
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    # Enable SSL
    ssl_certificate "C:/laragon/etc/ssl/laragon.crt";
    ssl_certificate_key "C:/laragon/etc/ssl/laragon.key";
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

    # Enable HSTS
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;


    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    location ~ /\.ht {
        deny all;
    }
}

# This file is auto-generated.
# If you want Laragon to respect your changes, just remove the [auto.] prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment