Finish headless Debian operation and document CDN origin deployment

This commit is contained in:
Codex
2026-10-11 19:22:52 +08:00
parent ab4e4a4f79
commit 4b62c33ed9
5 changed files with 92 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Preserve existing sites. Prefer a domain certificate; CDN IP origins can use
# the server's existing valid IP certificate when HTTP-01 is unavailable.
set -euo pipefail
root=/opt/kaoyan-studio-deploy/app
test -f /etc/nginx/kaoyan-studio.htpasswd
python3 - <<'PY'
from pathlib import Path
root = Path('/opt/kaoyan-studio-deploy/app/deploy')
text = (root / 'nginx-http-bootstrap.conf').read_text() + '\n' + (root / 'nginx-https.conf').read_text()
cert = Path('/etc/letsencrypt/live/kaoyan.fjayson.com/fullchain.pem')
if not cert.exists():
replacement = '/etc/letsencrypt/live/186.241.68.230/'
if not Path(replacement, 'fullchain.pem').exists():
raise SystemExit('Install a valid origin certificate before configuring HTTPS')
text = text.replace('/etc/letsencrypt/live/kaoyan.fjayson.com/', replacement)
Path('/etc/nginx/sites-available/kaoyan-studio').write_text(text)
PY
ln -sfn /etc/nginx/sites-available/kaoyan-studio /etc/nginx/sites-enabled/kaoyan-studio
nginx -t
systemctl reload nginx
+5
View File
@@ -8,6 +8,11 @@ server {
client_max_body_size 100m;
auth_basic "Kaoyan Workbench";
auth_basic_user_file /etc/nginx/kaoyan-studio.htpasswd;
location ^~ /.well-known/acme-challenge/ {
root /var/www/kaoyan-acme;
auth_basic off;
add_header Cache-Control no-store;
}
location / {
proxy_pass http://127.0.0.1:8765;
proxy_set_header Host $http_host;