Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tomquas/25a4b5cf87b193380fc0dc762daf3c24 to your computer and use it in GitHub Desktop.

Select an option

Save tomquas/25a4b5cf87b193380fc0dc762daf3c24 to your computer and use it in GitHub Desktop.

Revisions

  1. @disintegrator disintegrator renamed this gist Oct 30, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @disintegrator disintegrator revised this gist Oct 30, 2018. No changes.
  3. @disintegrator disintegrator created this gist Oct 30, 2018.
    37 changes: 37 additions & 0 deletions https-during-dev.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    brew install caddy mkcert nss dnsmasq

    mkcert -install

    mkcert '*.app.test' '*.cdn.test'

    # rename the certs and move them under /usr/local/etc/caddy/certs

    cat <<EOF > /usr/local/etc/caddy/Caddyfile
    *.app.test:443, *.cdn.test:443 {
    tls /usr/local/etc/caddy/certs/dev.pem /usr/local/etc/caddy/certs/dev-key.pem
    gzip
    proxy / localhost:3000 {
    transparent
    }
    }
    EOF

    cat <<EOF >> /usr/local/etc/dnsmasq.conf
    port=53
    address=/.test/127.0.0.1
    EOF

    sudo echo "nameserver 127.0.0.1" > /etc/resolver/test

    sudo brew services start dnsmasq

    scutil --dns
    # dnsmasq setup is successful if you see an entry for test domain like this:
    # resolver #8
    # domain : test
    # nameserver[0] : 127.0.0.1
    # flags : Request A records, Request AAAA records
    # reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)

    sudo caddy -conf /usr/local/etc/caddy/Caddyfile
    # optional: configure launchd to have caddy run on startup