study-online/nginx-localhost.conf
2025-08-04 15:24:49 +08:00

45 lines
1.7 KiB
Plaintext

server {
listen 9010;
server_name localhost 127.0.0.1 14.103.170.252;
# 火山引擎API代理
location /api/volcengine/ {
proxy_pass https://openspeech.bytedance.com/api/v1/auc/;
proxy_set_header Host openspeech.bytedance.com;
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;
# 处理CORS
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, 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';
# 处理OPTIONS预检请求
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, 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 Access-Control-Max-Age 1728000;
add_header Content-Type 'text/plain; charset=utf-8';
add_header Content-Length 0;
return 204;
}
# 超时设置
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
# 日志记录
access_log /var/log/nginx/volcengine_access.log;
error_log /var/log/nginx/volcengine_error.log;
}
location / {
alias /yantoo/frontend/study-online/;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}