zhizhi/deploy/nginx/dev-sandbox.conf

55 lines
1.5 KiB
Plaintext
Raw Normal View History

# 开发者子域名沙箱 · 自动匹配
# 指令ZY-AGEOS-TOWER-2026-0326-001
# 版权:国作登字-2026-A-00037559
#
# 需要冰朔配置:
# 1. DNS: *.guanghulab.com → A → 8.155.62.235
# 2. SSL: certbot certonly --dns 模式获取通配符证书 *.guanghulab.com
# HTTP → HTTPS 重定向
server {
listen 80;
server_name ~^(?<devid>dev-\d{3})\.guanghulab\.com$;
return 301 https://$host$request_uri;
}
# HTTPS 子域名沙箱
server {
listen 443 ssl;
server_name ~^(?<devid>dev-\d{3})\.guanghulab\.com$;
# SSL 证书(通配符证书 *.guanghulab.com
ssl_certificate /etc/letsencrypt/live/guanghulab.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/guanghulab.com/privkey.pem;
# 每个开发者的沙箱目录
root /var/www/sandbox/$devid;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# 安全头
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-Sandbox-DevId $devid;
# 日志
access_log /var/log/nginx/sandbox-$devid-access.log;
error_log /var/log/nginx/sandbox-error.log;
}
# 行业子域名(后期启用)
# server {
# listen 443 ssl;
# server_name writing.guanghulab.com;
# ssl_certificate /etc/letsencrypt/live/guanghulab.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/guanghulab.com/privkey.pem;
# root /var/www/industry/writing;
# index index.html;
# location / {
# try_files $uri $uri/ /index.html;
# }
# }