ledns -> roundrobin

This commit is contained in:
Zsolt Ero
2024-11-08 20:18:22 +01:00
parent d8c41202dc
commit 474d52b4c5
11 changed files with 53 additions and 53 deletions

View File

@@ -1,2 +0,0 @@
# once per day
2 34 * * * ofm sudo /usr/bin/bash /data/ofm/http_host/bin/ledns_reader.sh >> /data/ofm/http_host/logs/ledns_reader.log 2>&1

View File

@@ -0,0 +1,2 @@
# once per day
2 34 * * * ofm sudo /usr/bin/bash /data/ofm/http_host/bin/roundrobin_reader.sh >> /data/ofm/http_host/logs/roundrobin_reader.log 2>&1

View File

@@ -16,7 +16,7 @@ def write_nginx_config():
curl_text_mix = ''
domain_le = config.ofm_config['domain_le']
domain_ledns = config.ofm_config['domain_ledns']
domain_roundrobin = config.ofm_config['domain_roundrobin']
skip_letsencrypt = config.ofm_config['skip_letsencrypt']
# remove old configs and certs
@@ -27,18 +27,18 @@ def write_nginx_config():
file.unlink()
# processing Round Robin DNS config
if domain_ledns:
if domain_roundrobin:
if not config.rclone_config.is_file():
sys.exit('rclone.conf missing')
# download the ledns certificate from bucket using rclone
write_ledns_reader_script(domain_ledns)
subprocess.run(['bash', config.http_host_bin / 'ledns_reader.sh'], check=True)
# download the roundrobin certificate from bucket using rclone
write_roundrobin_reader_script(domain_roundrobin)
subprocess.run(['bash', config.http_host_bin / 'roundrobin_reader.sh'], check=True)
curl_text_mix += create_nginx_conf(
template_path=config.nginx_confs / 'ledns.conf',
local='ofm_ledns',
domain=domain_ledns,
template_path=config.nginx_confs / 'roundrobin.conf',
local='ofm_roundrobin',
domain=domain_roundrobin,
)
# processing Let's Encrypt config
@@ -317,13 +317,13 @@ def create_latest_locations(*, local: str, domain: str) -> str:
return location_str
def write_ledns_reader_script(domain_ledns):
def write_roundrobin_reader_script(domain_roundrobin):
script = f"""
#!/usr/bin/env bash
export RCLONE_CONFIG=/data/ofm/config/rclone.conf
rclone copyto -v "remote:ofm-private/ledns/{domain_ledns}/ofm_ledns.cert" /data/nginx/certs/ofm_ledns.cert
rclone copyto -v "remote:ofm-private/ledns/{domain_ledns}/ofm_ledns.key" /data/nginx/certs/ofm_ledns.key
rclone copyto -v "remote:ofm-private/roundrobin/{domain_roundrobin}/ofm_roundrobin.cert" /data/nginx/certs/ofm_roundrobin.cert
rclone copyto -v "remote:ofm-private/roundrobin/{domain_roundrobin}/ofm_roundrobin.key" /data/nginx/certs/ofm_roundrobin.key
""".strip()
with open(config.http_host_bin / 'ledns_reader.sh', 'w') as fp:
with open(config.http_host_bin / 'roundrobin_reader.sh', 'w') as fp:
fp.write(script)

View File

@@ -8,8 +8,8 @@ server {
listen [::]:443 ssl;
http2 on;
ssl_certificate /data/nginx/certs/ofm_ledns.cert;
ssl_certificate_key /data/nginx/certs/ofm_ledns.key;
ssl_certificate /data/nginx/certs/ofm_roundrobin.cert;
ssl_certificate_key /data/nginx/certs/ofm_roundrobin.key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
@@ -24,9 +24,9 @@ server {
# access log doesn't contain IP address
#access_log off;
access_log /data/ofm/http_host/logs_nginx/ledns-access.jsonl access_json buffer=128k;
access_log /data/ofm/http_host/logs_nginx/roundrobin-access.jsonl access_json buffer=128k;
error_log /data/ofm/http_host/logs_nginx/ledns-error.log;
error_log /data/ofm/http_host/logs_nginx/roundrobin-error.log;
__LOCATION_BLOCKS__
@@ -51,6 +51,6 @@ server {
# catch-all block to deny all other requests
location / {
deny all;
error_log /data/ofm/http_host/logs_nginx/ledns-deny.log error;
error_log /data/ofm/http_host/logs_nginx/roundrobin-deny.log error;
}
}