Added per-subdomain proxy flag to config.json

This commit is contained in:
Timothy Miller 2022-07-30 20:24:27 -04:00
parent 2401e7a995
commit 86976e5133
5 changed files with 86 additions and 89 deletions

View File

@ -21,8 +21,8 @@ Stale, duplicate DNS records are removed for housekeeping.
## 📊 Stats ## 📊 Stats
| Size | Downloads | Discord | | Size | Downloads | Discord |
| ------------- | ------------- | ------------- | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![cloudflare-ddns docker image size](https://img.shields.io/docker/image-size/timothyjmiller/cloudflare-ddns?style=flat-square)](https://hub.docker.com/r/timothyjmiller/cloudflare-ddns "cloudflare-ddns docker image size") | [![Total DockerHub pulls](https://img.shields.io/docker/pulls/timothyjmiller/cloudflare-ddns?style=flat-square)](https://hub.docker.com/r/timothyjmiller/cloudflare-ddns "Total DockerHub pulls") | [![Official Discord Server](https://img.shields.io/discord/785778163887112192?style=flat-square)](https://discord.gg/UgGmwMvNxm "Official Discord Server") | [![cloudflare-ddns docker image size](https://img.shields.io/docker/image-size/timothyjmiller/cloudflare-ddns?style=flat-square)](https://hub.docker.com/r/timothyjmiller/cloudflare-ddns 'cloudflare-ddns docker image size') | [![Total DockerHub pulls](https://img.shields.io/docker/pulls/timothyjmiller/cloudflare-ddns?style=flat-square)](https://hub.docker.com/r/timothyjmiller/cloudflare-ddns 'Total DockerHub pulls') | [![Official Discord Server](https://img.shields.io/discord/785778163887112192?style=flat-square)](https://discord.gg/UgGmwMvNxm 'Official Discord Server') |
## ⁉️ How Private & Secure? ## ⁉️ How Private & Secure?
@ -86,7 +86,7 @@ You can save yourself some trouble when hosting multiple domains pointing to the
## 🌐 Hosting multiple domains (zones) on the same IP? ## 🌐 Hosting multiple domains (zones) on the same IP?
You can handle ddns for multiple domains (cloudflare zones) using the same docker container by separating your configs inside ```config.json``` like below: You can handle ddns for multiple domains (cloudflare zones) using the same docker container by separating your configs inside `config.json` like below:
### ⚠️ Note ### ⚠️ Note
@ -105,28 +105,21 @@ Do not include the base domain name in your `subdomains` config. Do not use the
}, },
"zone_id": "your_zone_id_here", "zone_id": "your_zone_id_here",
"subdomains": [ "subdomains": [
"", {
"remove_or_replace_with_your_subdomain" "name": "",
], "proxied": false
"proxied": true
}, },
{ {
"authentication": { "name": "remove_or_replace_with_your_subdomain",
"api_token": "api_token_here", "proxied": false
"api_key": {
"api_key": "api_key_here",
"account_email": "your_email_here"
}
},
"zone_id": "your_zone_id_here",
"subdomains": [
"",
"remove_or_replace_with_your_subdomain"
],
"proxied": true
} }
] ]
} }
],
"a": true,
"aaaa": true,
"purgeUnknownRecords": false
}
``` ```
## 🐳 Deploy with Docker Compose ## 🐳 Deploy with Docker Compose
@ -136,14 +129,14 @@ Pre-compiled images are available via [the official docker container on DockerHu
Modify the host file path of config.json inside the volumes section of docker-compose.yml. Modify the host file path of config.json inside the volumes section of docker-compose.yml.
```yml ```yml
version: "3.7" version: '3.7'
services: services:
cloudflare-ddns: cloudflare-ddns:
image: timothyjmiller/cloudflare-ddns:latest image: timothyjmiller/cloudflare-ddns:latest
container_name: cloudflare-ddns container_name: cloudflare-ddns
security_opt: security_opt:
- no-new-privileges:true - no-new-privileges:true
network_mode: "host" network_mode: 'host'
environment: environment:
- PUID=1000 - PUID=1000
- PGID=1000 - PGID=1000
@ -166,7 +159,6 @@ docker-compose up -d
## 🐋 Kubernetes ## 🐋 Kubernetes
Create config File Create config File
```bash ```bash
@ -174,6 +166,7 @@ cp ../../config-example.json config.json
``` ```
Edit config.jsonon (vim, nvim, nano... ) Edit config.jsonon (vim, nvim, nano... )
```bash ```bash
${EDITOR} config.json ${EDITOR} config.json
``` ```
@ -197,7 +190,6 @@ apply this Deployment
kubectl apply -f cloudflare-ddns-Deployment.yaml kubectl apply -f cloudflare-ddns-Deployment.yaml
``` ```
## 🐧 Deploy with Linux + Cron ## 🐧 Deploy with Linux + Cron
### 🏃 Running (all distros) ### 🏃 Running (all distros)

View File

@ -6,7 +6,7 @@
# A small, 🕵️ privacy centric, and ⚡ # A small, 🕵️ privacy centric, and ⚡
# lightning fast multi-architecture Docker image for self hosting projects. # lightning fast multi-architecture Docker image for self hosting projects.
__version__ = "1.0.1" __version__ = "1.0.2"
import json import json
import os import os
@ -105,15 +105,16 @@ def commitRecord(ip):
base_domain_name = response["result"]["name"] base_domain_name = response["result"]["name"]
ttl = 300 # default Cloudflare TTL ttl = 300 # default Cloudflare TTL
for subdomain in subdomains: for subdomain in subdomains:
subdomain = subdomain.lower().strip() name = subdomain["name"].lower().strip()
fqdn = base_domain_name fqdn = base_domain_name
if subdomain != '' and subdomain != '*' and subdomain != '@': # Check if name provided is a reference to the root domain
fqdn = subdomain + "." + base_domain_name if name != '' and name != '*' and name != '@':
fqdn = name + "." + base_domain_name
record = { record = {
"type": ip["type"], "type": ip["type"],
"name": fqdn, "name": fqdn,
"content": ip["ip"], "content": ip["ip"],
"proxied": option["proxied"], "proxied": subdomain["proxied"],
"ttl": ttl "ttl": ttl
} }
dns_records = cf_api( dns_records = cf_api(

View File

@ -10,10 +10,15 @@
}, },
"zone_id": "your_zone_id_here", "zone_id": "your_zone_id_here",
"subdomains": [ "subdomains": [
"", {
"remove_or_replace_with_your_subdomain" "name": "",
],
"proxied": false "proxied": false
},
{
"name": "remove_or_replace_with_your_subdomain",
"proxied": false
}
]
} }
], ],
"a": true, "a": true,

View File

@ -1,34 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloudflate-ddns
spec:
selector:
matchLabels:
app: cloudflate-ddns
template:
metadata:
labels:
app: cloudflate-ddns
spec:
containers:
- name: cloudflate-ddns
image: timothyjmiller/cloudflare-ddns:latest
#image: quay.io/arpagon/cloudflare-ddns:v1.0.0
resources:
limits:
memory: "32Mi"
cpu: "50m"
env:
- name: CONFIG_PATH
value: "/etc/cloudflare-ddns/"
volumeMounts:
- mountPath: "/etc/cloudflare-ddns"
name: config-cloudflare-ddns
readOnly: true
volumes:
- name: config-cloudflare-ddns
secret:
secretName: config-cloudflare-ddns

33
k8s/cloudflare-ddns.yml Normal file
View File

@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloudflare-ddns
spec:
selector:
matchLabels:
app: cloudflare-ddns
template:
metadata:
labels:
app: cloudflare-ddns
spec:
containers:
- name: cloudflare-ddns
image: timothyjmiller/cloudflare-ddns:latest
resources:
limits:
memory: '32Mi'
cpu: '50m'
env:
- name: CONFIG_PATH
value: '/etc/cloudflare-ddns/'
volumeMounts:
- mountPath: '/etc/cloudflare-ddns'
name: config-cloudflare-ddns
readOnly: true
volumes:
- name: config-cloudflare-ddns
secret:
secretName: config-cloudflare-ddns