Created
September 27, 2022 09:38
-
-
Save lohazo/90dcaae3966172f530b4724ac0c75b7e to your computer and use it in GitHub Desktop.
https-localhost.macos.sh
This file contains hidden or 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 | |
# test could be anything | |
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