[Apache2] [mod_substitute] [mod_filter]替换/过滤/重写动态ProxyPassed HTML内容

时间:2014-03-20 13:09:14

标签: html apache dynamic

我们正在尝试重写ProxyPassed网站的HTML内容(链接)。 我们尝试过这样的事情:http://lamshing.blogspot.de/2010/10/on-fly-subsitution-of-text-with.html,但无济于事。 现在仍然坚持:Apache AddOutputFilterByType is deprecated. How to rewrite using mod_filter?

包含文件中的Conent(如* .css)被替换,但不是" root"内容。 我们已经读过,ProxyPassed内容有一个"未知类型" - >过滤器不会生效。

你们有什么线索,如何能够在动态的AND ProxyPassed环境中替换某些东西?

我们当前的配置:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

Header set TEST ";charset=utf-8"
Header edit TEST ^\s*;charset=utf-8\s*$ "text/html; charset=utf-8"

FilterDeclare MYFILTER
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $*
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/xml
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/json
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/javascript
        <Location />
                FilterChain MYFILTER
                Substitute "s/You have/AAAAAAAAAAAAAAAAAAAAAAAAA/ni"
        </Location>
        RewriteEngine On
        ServerSignature Off



        ProxyRequests Off


        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>

        ProxyPass / http://hmpg.net/
        ProxyPassReverse / http://hmpg.net/


</VirtualHost>

2 个答案:

答案 0 :(得分:0)

我们得到了它,gzip就是问题。

在位置/添加:

RequestHeader取消设置Accept-Encoding

不使用FilterChain,只需添加以下内容:

&#34; foo1337 = k时,条= K&#34;

替换&#34; s | foo([0-9] +)= k,bar \ 1 = k | foo / bar = $ 1&#34;

- &GT; &#34;富/酒吧= 1337&#34;

答案 1 :(得分:0)

注意新的FilterProvider参数设置,例如:

FilterProvider MYFILTER SUBSTITUTE "%{Content_Type} =~ |^text/html|"