Files
Mymusic3/nginx.conf.example
2026-01-14 18:09:16 +08:00

43 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

server {
listen 80;
server_name your-domain.com;
# 前端静态资源 (Music Canvas)
location / {
proxy_pass http://127.0.0.1:7481;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
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 代理
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';
}
}