小编Pau*_*ent的帖子

Apache2 mod_substitute 无法在 <Location> 中工作

我有一个正在工作的反向代理,它仅在我的站点中的特定位置上处于活动状态,在本例中例如:www.example.com/reverseproxy/site1我正在反向代理 site1。我想替换每个代理页面正文的某些部分,所以我尝试使用 mod_substitute,问题是我无法让它在<Location /reverseproxy>

这是我的 httpd(启用了 SSL):

<VirtualHost _default_:443> 

    ProxyPassInterpolateEnv On
    RewriteEngine On

    ... Some rewrite rules
    RewriteRule /?reverseproxy/http(s*):/([^\/]*)/*(.*) "http$1://$2/$3" [P]
    SSLProxyEngine On
    ProxyPassReverse "/reverseproxy/http${ssl}://${page}" http${ssl}://${page} interpolate

    SetOutputFilter INFLATE;proxy-html;SUBSTITUTE;DEFLATE;
    ProxyHTMLInterp On
    ProxyHTMLExtended Off

    ...Some ProxyURLMap
    AddOutputFilterByType SUBSTITUTE text/html
    Substitute "s|<body>|<body1>|"
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

这个替代品确实有效,但它适用于所有页面,而不仅仅是/reverseproxy. 当我尝试将其放入时,<Location /reverseproxy>它不起作用,它只是忽略它:

<Location /reverseproxy>
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<body>|<body1>|"
</Location>
Run Code Online (Sandbox Code Playgroud)

我尝试过的:

我尝试添加

 RequestHeader unset Accept-Encoding
Run Code Online (Sandbox Code Playgroud)

在标签之外<Location>但它不起作用

我尝试添加这个

SetOutputFilter SUBSTITUTE;DEFLATE
Run Code Online (Sandbox Code Playgroud)

<Location /reverseproxy>标签中但没有运气

正如有人建议尝试使用这个过滤器链

FilterDeclare filter
FilterProvider filter SUBSTITUTE …
Run Code Online (Sandbox Code Playgroud)

mod-rewrite reverse-proxy mod-proxy apache-2.4 apache2

5
推荐指数
1
解决办法
3837
查看次数