surmon-china/surmon.me

哔哩哔哩那块的视频封面的nginx反向代理该如何配置

yah0130 opened this issue · 3 comments

哔哩哔哩那块的反代我配置好后,访问会出现403,这块反向代理配置应该如何配,大佬能帮忙解惑吗

nginx 里的配置需要自己配,但开发环境下的 基本反代 就可以确保「能工作」

nginx 里的配置需要自己配,但开发环境下的 基本反代 就可以确保「能工作」

我上生产环境后的nginx配置是这样的:
location ~ "^/proxy/bilibili/(.*)$" {
resolver 114.114.114.114 114.114.115.115 8.8.8.8 valid=300s;
resolver_timeout 10s;
proxy_pass https://$1$is_args$args;
}

但是发现会报403错误,试了好多方法都没解决,大佬能帮个忙吗

请问反代网易云音乐的封面和音乐你是怎么配置的,能给一个指示吗
网易云
location ~ ^/proxy/music/(.*) {
resolver 114.114.114.114 114.114.115.115 8.8.8.8 valid=300s;
resolver_timeout 10s;

        proxy_redirect off;
        proxy_pass http://$1$is_args$args;
        
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header User-Agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3223.8 Safari/537.36";
        
        # 忽略相关header信息,使缓存最大化生效
        proxy_ignore_headers Set-Cookie Cache-Control;
        proxy_hide_header Cache-Control;
        proxy_hide_header Set-Cookie;
     
        expires 7d;
    }

bilibili
location ~ ^/proxy/bilibili/(.*) {
proxy_set_header Referer "https://www.bilibili.com";

        resolver 114.114.114.114 114.114.115.115 8.8.8.8 valid=300s;
        resolver_timeout 10s;
        
        proxy_redirect off;
        proxy_pass http://$1$is_args$args;
        
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header User-Agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3223.8 Safari/537.36";
        
        
        # 忽略相关header信息,使缓存最大化生效
        proxy_ignore_headers Set-Cookie Cache-Control;
        proxy_hide_header Cache-Control;
        proxy_hide_header Set-Cookie;
     
        expires 7d;
    }