平台开发中,欢迎参与测试。你可以在 QQ群:1046115671 中与我们交流,或是直接在社区发帖
  • 孙锡源
    管理员

    把你完整的nginx配置文件贴上来。论坛编辑器有贴代码功能

  • 小可哥哥
    楼主
    #PROXY-START/
    location ~* \.(gif|png|jpg|css|js|woff|woff2)$
    {
           proxy_pass https://cmsstaticv2.ffquan.cn;
        proxy_set_header Host cmsstaticv2.ffquan.cn;
        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://cmsstaticv2.ffquan.cn;
        proxy_set_header Host cmsstaticv2.ffquan.cn;
        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;
        
        #Set Nginx Cache
           
    
    
    
       	sub_filter_types *;
    
           proxy_set_header Accept-Encoding "";    
    
        sub_filter "ffquan" "xiaoke";
        
        sub_filter_once off;
        	add_header Cache-Control no-cache;
    }
    
    #PROXY-END/

    https://fandai1.xiaoke.name/asset-manifest.json

    可以替换成功

    https://fandai1.xiaoke.name/js/app.591f9646.js

    替换无效

  • 孙锡源
    管理员

    location 匹配的原则是从长到短,所以你上面的配置文件中 app.591f9646.js 匹配到的是以下块:

    location ~* \.(gif|png|jpg|css|js|woff|woff2)$
    {
        proxy_pass https://cmsstaticv2.ffquan.cn;
        proxy_set_header Host cmsstaticv2.ffquan.cn;
        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;
    }

    想对关键字替换的话就把替换相关的配置提升到全局作用域上

    • 小可哥哥
      楼主
      #PROXY-START/
      
      location /
      {
          proxy_pass https://cmsstaticv2.ffquan.cn;
          proxy_set_header Host cmsstaticv2.ffquan.cn;
          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;
          
          #Set Nginx Cache
             
      
         	sub_filter_types *;
      
             proxy_set_header Accept-Encoding "";    
      
          sub_filter "ffquan" "xiaoke";
          
          sub_filter_once off;
          	add_header Cache-Control no-cache;
      }
      
      #PROXY-END/
      #PROXY-START/
      location ~* \.(gif|png|jpg|css|js|woff|woff2)$
      {
          proxy_pass https://cmsstaticv2.ffquan.cn;
          proxy_set_header Host cmsstaticv2.ffquan.cn;
          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;
          
          sub_filter_types *;
          proxy_set_header Accept-Encoding "";    
          sub_filter "ffquan" "xiaoke";
          sub_filter_once off;
      }
      location /
      {
          proxy_pass https://cmsstaticv2.ffquan.cn;
          proxy_set_header Host cmsstaticv2.ffquan.cn;
          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;
          
          #Set Nginx Cache
             
      
          sub_filter_types *;
      
          proxy_set_header Accept-Encoding "";    
      
          sub_filter "ffquan" "xiaoke";
          
          sub_filter_once off;
          add_header Cache-Control no-cache;
      }
      
      #PROXY-END/

      改成这2段还是无效啊

    • 孙锡源
      管理员

      我测试看已经生效了。你 ctrl+f5 刷新看看,或者在 url 后面追加个随机参数

  • 正在查看 3 条回复
    • 哎呀,回复话题必需登录。

    加入 LitePress 论坛 ,参与知识分享与交流
    登录 注册 进行评论
    立即加入