xizeyoupan / Meting-API

🐳 Meting API 的容器化与部署
https://meting-dd.2333332.xyz
208 stars 207 forks source link

无法加载歌词 #27

Closed Xiaotingwen closed 5 months ago

Xiaotingwen commented 5 months ago

大佬好,我的API搭建在国外的服务器,但是访问api首页时显示我是部署在国内,在反代后,域名访问API地址无法显示歌词的,但是使用IP:端口是可以的,这是啥情况?

xizeyoupan commented 5 months ago

贴下反代配置,如果可以贴一下网址

Xiaotingwen commented 5 months ago

贴下反代配置,如果可以贴一下网址

我用的是1panel,所以有两个位置文件

网址:https://musicapi.404n.cn/test

反代配置: server { listen 80 ; listen 443 ssl http2 ; server_name musicapi.404n.cn; index index.php index.html index.htm default.php default.htm default.html; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; access_log /www/sites/musicapi.404n.cn/log/access.log main; error_log /www/sites/musicapi.404n.cn/log/error.log; location ^~ /.well-known/acme-challenge { allow all; root /usr/share/nginx/html; } include /www/sites/musicapi.404n.cn/proxy/.conf; if ($scheme = http) { return 301 https://$host$request_uri; } ssl_certificate /www/sites/musicapi.404n.cn/ssl/fullchain.pem; ssl_certificate_key /www/sites/musicapi.404n.cn/ssl/privkey.pem; ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; error_page 497 https://$host$request_uri; proxy_set_header X-Forwarded-Proto https; ssl_stapling on; ssl_stapling_verify on; location ~ ..(js|css|png|jpg|jpeg|gif|ico|bmp|swf|eot|svg|ttf|woff|woff2)$ { log_not_found off; valid_referers none musicapi.404n.cn; if ($invalid_referer) { return 404; access_log off; } } }

image

xizeyoupan commented 5 months ago

看下readme,反代加一下 proxy_set_header X-Forwarded-Host $scheme://$host:$server_port;

Xiaotingwen commented 5 months ago

看下readme,反代加一下 proxy_set_header X-Forwarded-Host $scheme://$host:$server_port;

我尝试加过,好像没效果,是不是我整的有问题。。。 尝试1: server { listen 80 ; listen 443 ssl http2 ; server_name musicapi.404n.cn; index index.php index.html index.htm default.php default.htm default.html; proxy_set_header X-Forwarded-Host $scheme://$host:$server_port; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr;

尝试2: server { listen 80 ; listen 443 ssl http2 ; server_name musicapi.404n.cn; index index.php index.html index.htm default.php default.htm default.html; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; access_log /www/sites/musicapi.404n.cn/log/access.log main; error_log /www/sites/musicapi.404n.cn/log/error.log; location ^~ /.well-known/acme-challenge { allow all; root /usr/share/nginx/html; } location /meting/ { proxy_pass http://localhost:3000/; proxy_set_header X-Forwarded-Host $scheme://$host:$server_port/meting; } include /www/sites/musicapi.404n.cn/proxy/.conf; if ($scheme = http) { return 301 https://$host$request_uri; } ssl_certificate /www/sites/musicapi.404n.cn/ssl/fullchain.pem; ssl_certificate_key /www/sites/musicapi.404n.cn/ssl/privkey.pem; ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; error_page 497 https://$host$request_uri; proxy_set_header X-Forwarded-Proto https; ssl_stapling on; ssl_stapling_verify on; location ~ ..(js|css|png|jpg|jpeg|gif|ico|bmp|swf|eot|svg|ttf|woff|woff2)$ { log_not_found off; valid_referers none musicapi.404n.cn; if ($invalid_referer) { return 404; access_log off; } } }

xizeyoupan commented 5 months ago

贴下反代配置,如果可以贴一下网址

我用的是1panel,所以有两个位置文件

网址:https://musicapi.404n.cn/test

反代配置: server { listen 80 ; listen 443 ssl http2 ; server_name musicapi.404n.cn; index index.php index.html index.htm default.php default.htm default.html; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; access_log /www/sites/musicapi.404n.cn/log/access.log main; error_log /www/sites/musicapi.404n.cn/log/error.log; location ^~ /.well-known/acme-challenge { allow all; root /usr/share/nginx/html; } include /www/sites/musicapi.404n.cn/proxy/.conf; if ($scheme = http) { return 301 https://$host$request_uri; } ssl_certificate /www/sites/musicapi.404n.cn/ssl/fullchain.pem; ssl_certificate_key /www/sites/musicapi.404n.cn/ssl/privkey.pem; ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; error_page 497 https://$host$request_uri; proxy_set_header X-Forwarded-Proto https; ssl_stapling on; ssl_stapling_verify on; location ~ ..(js|css|png|jpg|jpeg|gif|ico|bmp|swf|eot|svg|ttf|woff|woff2)$ { log_not_found off; valid_referers none musicapi.404n.cn; if ($invalid_referer) { return 404; access_log off; } } }

image

这里改成 proxy_set_header X-Forwarded-Host $scheme://$server_name; 试下,另外部署在国外要把OVERSEAS环境变量设为1

Xiaotingwen commented 5 months ago

贴下反代配置,如果可以贴一下网址

我用的是1panel,所以有两个位置文件 网址:https://musicapi.404n.cn/test 反代配置: server { listen 80 ; listen 443 ssl http2 ; server_name musicapi.404n.cn; index index.php index.html index.htm default.php default.htm default.html; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; access_log /www/sites/musicapi.404n.cn/log/access.log main; errorlog /www/sites/musicapi.404n.cn/log/error.log; location ^~ /.well-known/acme-challenge { allow all; root /usr/share/nginx/html; } include /www/sites/musicapi.404n.cn/proxy/.conf; if ($scheme = http) { return 301 https://$host$request_uri; } ssl_certificate /www/sites/musicapi.404n.cn/ssl/fullchain.pem; ssl_certificate_key /www/sites/musicapi.404n.cn/ssl/privkey.pem; ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; error_page 497 https://$host$request_uri; proxy_set_header X-Forwarded-Proto https; ssl_stapling on; ssl_staplingverify on; location ~ ..(js|css|png|jpg|jpeg|gif|ico|bmp|swf|eot|svg|ttf|woff|woff2)$ { log_not_found off; valid_referers none musicapi.404n.cn; if ($invalid_referer) { return 404; access_log off; } } } image

这里改成 proxy_set_header X-Forwarded-Host $scheme://$server_name; 试下,另外部署在国外要把OVERSEAS环境变量设为1

还是大佬牛,在这个位置加了这条之后可以了,部署使用的别人的docker-compose.yml,他的配置中没写这个环境变量,所以就没有设置