这篇文章上次修改于 864 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

# PROXY-START/
location ~* \.(gif|png|jpg|css|js|woff|woff2)$
{
proxy_pass https://www.xxxx.com;
    proxy_set_header Host www.xxxx.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    ##expires 12h;
}
location ~* ^/(.*)$ {
    proxy_pass https://www.xxxx.com;
    proxy_set_header Host www.xxxx.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    add_header X-Cache $upstream_cache_status;
    proxy_ignore_headers Set-Cookie Cache-Control expires;
    add_header Cache-Control no-cache;
}
# PROXY-END/
 

备注:反代后,记得在源站中的宝塔面板中的nginx防火墙中,设置IP白名单。