March 12, 2024 - Reading time: 2 minutes
I'll be saving my data in ~/docker in this example
cd docker (mkdir docker if you don't have it)mkdir traefik and cd traefik nano docker-compose.yml [Template]Replace admin:123 with a secure loginecho $(htpasswd -nb "admin" "123") | sed -e s/\\$/\\$\\$/g
Use the result from this command
touch config.ymltouch acme.jsonnano traefik.ymlmkdir logssudo docker network create proxysudo docker compose up -dsudo docker compose logs -f (if you want to see logs) March 12, 2024 - Reading time: 3 minutes
Make an A record pointing to 8.8.8.8 with proxy off
Global Key here
https://dash.cloudflare.com/profile/api-tokens
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/Zone ID/dns_records?name=domain.tld" -H "X-Auth-Email: email@example.com" -H "X-Auth-Key: Global Key" -H "Content-Type: application/json"
Your result should start with something like below, let's call this THE ID
{"result":{"id":"he832434238hb327g" Put this in THE ID in the (and obviously fill in the other information we gathered)
Scroll down on the "Overview" tab and you will find your Zone ID
https://dash.cloudflare.com/somethingsomething/domain.tld
Now fill your Email, Global key, Zone ID & THE ID
curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/Zone ID/dns_records/THE ID" -H "X-Auth-Email:email@example.com" -H "X-Auth-Key:Global Key" -H "Content-Type: application/json" --data "{\"id\":\"Zone ID\",\"type\":\"A\",\"name\":\"domain.tld\",\"content\":\"$(curl https://ifconfig.co)\",\"proxied\":true}"
After running this command in your terminal you should see the A record has changed to your ip with the proxy enabled.
Marking the script run run automatically
1. mkdir /path/to/ddns.sh
2. chmod 700 /path/to/ddns.sh
3. Put the command we just made in here
nano /path/to/ddns.sh
4. crontab -e
5. */5 * * * * /path/to/ddns.sh >/dev/null 2>&1