修改了代理
This commit is contained in:
@@ -10,16 +10,32 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
# 音乐 API 代理 (解决 HTTPS 握手和 Host 问题)
|
||||
location /music-api {
|
||||
# 将 /music-api 映射到 /api
|
||||
# 例如: /music-api?source=... -> https://music-dl.sayqz.com/api?source=...
|
||||
rewrite ^/music-api/?(.*)$ /api/$1 break;
|
||||
|
||||
proxy_pass https://music-dl.sayqz.com;
|
||||
|
||||
# [关键] 开启 SSL Server Name Indication (SNI),否则 HTTPS 握手会失败
|
||||
proxy_ssl_server_name on;
|
||||
|
||||
# [关键] 设置正确的 Host 头,或者直接删掉这行让 Nginx 自动使用 proxy_pass 的域名
|
||||
# 千万不要设置为 $host,因为对方服务器不认识你的域名
|
||||
proxy_set_header Host music-dl.sayqz.com;
|
||||
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
# 同步服务 API 代理
|
||||
# 将 /api/kv/... 转发到 sync-service 的 7482 端口
|
||||
# 注意:这里去掉了 /api 前缀,因为 sync-service 直接监听 /kv
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:7482/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# 允许跨域 (如果前端和后端不在同一个域)
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
|
||||
Reference in New Issue
Block a user