Establish secure account and managed AI backend

Provide the production foundation for Apple identity, immutable credits, referrals, integrity checks, managed providers, and hardened Docker deployment.
This commit is contained in:
Rocky
2026-08-16 14:46:23 +08:00
commit 0af35d44f4
124 changed files with 21052 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# 1Panel / OpenResty 示例
1. 在 1Panel 创建 `account.osglab.com``osglab.com` 两个 HTTPS 网站并申请证书。
2.`deploy/openresty-account.conf``map``limit_req_zone``upstream` 放入
OpenResty `http` 上下文,其余 `server` 块作为站点配置。这是仓库内唯一的反向代理配置源。
3. 确认证书目录与示例一致;若 1Panel 实际路径不同,以面板生成的路径为准。
4. AASA 的两个无扩展名路径都直接代理到 Ktor,由生产配置生成 JSON;不要复制或维护静态
AASA 文件,也不要给 AASA 添加跳转、认证或缓存覆盖。
5. 先执行 `openresty -t`,配置检查通过后再在 1Panel 重载 OpenResty。
示例假定 `compose.yaml` 把应用映射到宿主机 `127.0.0.1:18080`。若 OpenResty
本身运行在容器中,应让它加入 `account-backend` 外部网络,并把 upstream 改为
`account-server:8080`;不要把应用端口绑定到公网地址。
使用 `docker network create --internal account-backend` 创建数据库网络,并将现有 MySQL
容器加入该网络;MySQL 不配置 `ports`。应用同时加入独立 egress 网络访问 Apple、火山
和 DeepSeek。
+123
View File
@@ -0,0 +1,123 @@
# Include this file from OpenResty's http block. The Compose service listens only
# on 127.0.0.1:18080, so clients cannot bypass these controls.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
limit_req_zone $binary_remote_addr zone=account_api:10m rate=20r/s;
limit_req_zone $binary_remote_addr zone=invite_page:10m rate=5r/s;
limit_req_status 429;
upstream osg_account_server {
server 127.0.0.1:18080;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name account.osglab.com;
return 308 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name account.osglab.com;
ssl_certificate /www/server/panel/vhost/cert/account.osglab.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/account.osglab.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_timeout 1d;
ssl_session_cache shared:account_tls:10m;
client_max_body_size 21m;
server_tokens off;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "no-referrer" always;
# Never publish operational or administrative paths through this vhost.
location ~ ^/(?:admin|internal|v1/admin)(?:/|$) {
return 404;
}
location / {
limit_req zone=account_api burst=40 nodelay;
proxy_pass http://osg_account_server;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Request-ID $request_id;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_hide_header Server;
proxy_request_buffering off;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 360s;
proxy_send_timeout 360s;
}
}
server {
listen 80;
listen [::]:80;
server_name osglab.com www.osglab.com;
return 308 https://osglab.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name osglab.com www.osglab.com;
ssl_certificate /www/server/panel/vhost/cert/osglab.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/osglab.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
server_tokens off;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer" always;
location = /.well-known/apple-app-site-association {
access_log off;
proxy_pass http://osg_account_server;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
}
location = /apple-app-site-association {
access_log off;
proxy_pass http://osg_account_server;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
}
# Invitation codes are bearer-like values and must not appear in access logs.
location ^~ /i/ {
access_log off;
limit_req zone=invite_page burst=10 nodelay;
proxy_pass http://osg_account_server;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Request-ID $request_id;
proxy_hide_header Server;
proxy_buffering off;
proxy_cache off;
}
# Keep the existing 1Panel site root for all non-invitation pages.
root /www/wwwroot/osglab.com;
location / {
try_files $uri $uri/ =404;
}
}