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
| 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?
@ -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?
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
@ -105,27 +105,20 @@ Do not include the base domain name in your `subdomains` config. Do not use the
},
"zone_id": "your_zone_id_here",
"subdomains": [
"",
"remove_or_replace_with_your_subdomain"
],
"proxied": true
{
"name": "",
"proxied": false
},
{
"authentication": {
"api_token": "api_token_here",
"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
"name": "remove_or_replace_with_your_subdomain",
"proxied": false
}
]
}
],
"a": true,
"aaaa": true,
"purgeUnknownRecords": false
}
```
@ -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.
```yml
version: "3.7"
version: '3.7'
services:
cloudflare-ddns:
image: timothyjmiller/cloudflare-ddns:latest
container_name: cloudflare-ddns
security_opt:
- no-new-privileges:true
network_mode: "host"
network_mode: 'host'
environment:
- PUID=1000
- PGID=1000
@ -166,38 +159,37 @@ docker-compose up -d
## 🐋 Kubernetes
Create config File
``` bash
```bash
cp ../../config-example.json config.json
```
Edit config.jsonon (vim, nvim, nano... )
``` bash
```bash
${EDITOR} config.json
```
Create config file as Secret.
``` bash
```bash
kubectl create secret generic config-cloudflare-ddns --from-file=config.json --dry-run=client -oyaml -n ddns > config-cloudflare-ddns-Secret.yaml
```
apply this secret
``` bash
```bash
kubectl apply -f config-cloudflare-ddns-Secret.yaml
rm config.json # recomended Just keep de secret on Kubernetes Cluster
```
apply this Deployment
``` bash
```bash
kubectl apply -f cloudflare-ddns-Deployment.yaml
```
## 🐧 Deploy with Linux + Cron
### 🏃 Running (all distros)

View File

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

View File

@ -10,10 +10,15 @@
},
"zone_id": "your_zone_id_here",
"subdomains": [
"",
"remove_or_replace_with_your_subdomain"
],
{
"name": "",
"proxied": false
},
{
"name": "remove_or_replace_with_your_subdomain",
"proxied": false
}
]
}
],
"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