宝塔双11特惠活动,企业版2299元/3年,SSL证书低至9.9元!查看活动
当前位置:论坛首页 > Linux面板 > 求助

【已解决】Linux下nginx反向代理无法替换js的内容

发表在 Linux面板2021-12-6 08:19 [复制链接] 2 3109

由于有个api的地址在js里,需要把js的内容替换掉,但是死活不行,其他内容可以,但是js里的内容不行。
配置大致是这样的

#PROXY-START/
location ~* \.(gif|png|jpg|css|js|woff|woff2)$
{
    proxy_pass https://www.xxxx.org;
    proxy_set_header Host www.xxxx.org;
    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.xxx.org/;
    sub_filter_types *;
    sub_filter "api.xxxxx.org" "api.xx.xxxx.cn";
    sub_filter_once off;
    proxy_set_header Host www.xxxx.org;
    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;
    proxy_set_header Accept-Encoding "";
    add_header X-Cache $upstream_cache_status;
        #Set Nginx Cache

    proxy_ignore_headers Set-Cookie Cache-Control expires;
    proxy_cache cache_one;
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_valid 200 304 301 302 1m;
}

使用道具 举报 只看该作者 回复
发表于 2021-12-6 09:15:47 | 显示全部楼层
location ~* \.(gif|png|jpg|css|js|woff|woff2)$
{
    proxy_pass https://www.xxxx.org;
    proxy_set_header Host www.xxxx.org;
    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;
}


面板上的反向代理没有做前后端分离,只做了单纯的反代功能,您把这段配置去掉试试
使用道具 举报 回复 支持 反对
发表于 2021-12-6 10:13:19 | 显示全部楼层
大炮运维V587 发表于 2021-12-6 09:15
面板上的反向代理没有做前后端分离,只做了单纯的反代功能,您把这段配置去掉试试 ...

搞定了,感谢
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表