69 lines
2.9 KiB
Plaintext
69 lines
2.9 KiB
Plaintext
# interview.test.ai.ireborn.com.cn Nginx 配置
|
|
# 宝塔面板配置:网站 -> 添加站点 -> 设置 -> 配置文件 -> 粘贴此内容
|
|
|
|
server {
|
|
listen 80;
|
|
listen 443 ssl http2;
|
|
server_name interview.test.ai.ireborn.com.cn;
|
|
|
|
index index.html;
|
|
|
|
# SSL 证书 (宝塔面板会自动生成,如果没有可以先注释掉 ssl 相关配置)
|
|
# ssl_certificate /www/server/panel/vhost/cert/interview.test.ai.ireborn.com.cn/fullchain.pem;
|
|
# ssl_certificate_key /www/server/panel/vhost/cert/interview.test.ai.ireborn.com.cn/privkey.pem;
|
|
# ssl_protocols TLSv1.2 TLSv1.3;
|
|
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
|
# ssl_prefer_server_ciphers on;
|
|
# ssl_session_timeout 10m;
|
|
# ssl_session_cache shared:SSL:10m;
|
|
|
|
# 日志
|
|
access_log /www/wwwlogs/interview.test.ai.ireborn.com.cn.log;
|
|
error_log /www/wwwlogs/interview.test.ai.ireborn.com.cn.error.log;
|
|
|
|
# 前端 - 代理到 Docker 前端容器 (3000 端口)
|
|
location / {
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
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 $scheme;
|
|
}
|
|
|
|
# API - 代理到 Docker 后端容器 (8000 端口)
|
|
location /api/ {
|
|
proxy_pass http://127.0.0.1:8000/api/;
|
|
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 $scheme;
|
|
proxy_read_timeout 120s;
|
|
proxy_connect_timeout 120s;
|
|
|
|
# CORS 配置
|
|
add_header Access-Control-Allow-Origin * always;
|
|
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS' always;
|
|
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always;
|
|
|
|
# 处理 OPTIONS 预检请求
|
|
if ($request_method = 'OPTIONS') {
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
|
|
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
|
|
add_header Content-Length 0;
|
|
return 204;
|
|
}
|
|
}
|
|
|
|
# 健康检查端点
|
|
location /health {
|
|
proxy_pass http://127.0.0.1:8000/health;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
}
|
|
}
|