V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
holinhot
V2EX  ›  NGINX

nginx 反代能不能在 head 里插入一段 js

  •  
  •   holinhot · 2015-05-26 13:57:45 +08:00 · 5150 次点击
    这是一个创建于 3264 天前的主题,其中的信息可能已经有所发展或是发生改变。

    header_string 好像插入的是最前面 都在html外了
    怎么能插入<head></head>之间

    11 条回复    2015-08-19 08:37:01 +08:00
    server
        1
    server  
       2015-05-26 14:00:25 +08:00
    记得伟大的Apache是可以,nginx没耍过。
    101
        2
    101  
       2015-05-26 14:02:13 +08:00
    可以,不过默认的功能不强,有第三方模块,搜索一下就能搞定
    holinhot
        3
    holinhot  
    OP
       2015-05-26 14:03:59 +08:00
    @server
    @101
    把</head>替换成
    xxxxxxxxxxxxxxxxxxxx</head>可行吗
    fising
        4
    fising  
       2015-05-26 14:05:54 +08:00
    当然可以。
    101
        5
    101  
       2015-05-26 14:06:49 +08:00
    可以啊 关键字 subs_filter
    falcon05
        6
    falcon05  
       2015-05-26 14:07:18 +08:00 via iPhone
    nginx有替代模块
    phithon
        8
    phithon  
       2015-05-26 14:56:15 +08:00
    sub_filter </head> "<script>xxx</script></head>"
    phithon
        9
    phithon  
       2015-05-26 14:57:53 +08:00
    不过要先把gzip关掉
    proxy_set_header Accept-Encoding "";
    sub_filter </head> "<script>xxx</script></head>"
    dallaslu
        10
    dallaslu  
       2015-05-26 22:58:44 +08:00
    可以 +1
    sky170
        11
    sky170  
       2015-08-19 08:37:01 +08:00 via iPhone
    可以,但是有些会乱
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2183 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 02:18 · PVG 10:18 · LAX 19:18 · JFK 22:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.