-
-
Save tomquas/25a4b5cf87b193380fc0dc762daf3c24 to your computer and use it in GitHub Desktop.
Use Caddy, mkcert and dnsmasq to expose your development server over HTTPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment