Hi, everyone!Sorry, I'm newbie in apache. After a few days of search. We use apache2.4 for our project.For some improve of our forward proxy compatibility. As we need hide some content from our client.So we use forward proxy and filter module. First we use nginx as the proxy. And some key config below:
location / { resolver 192.168.10.1; proxy_pass $scheme://$http_host$request_uri; sub_filter thatsneedchange thatschangethat; sub_filter_types application/json application/xhtml+xml text/html text/plain; sub_filter_once off; } so this can filte and replace the content on website for our client on the internet. But we met some problem can't resolve: Some of clients application didn't support the standard RFC.As we found the sub_filter module will delete every content-length header of the response. As the lack of the content-length, our client wouldn't accept that response. So we came up the apache module filter. As we find the document FilterProtocol Directive This directs mod_filter to deal with ensuring the filter doesn't run when it shouldn't, and that the HTTP response headers are correctly set taking into account the effects of the filter. There are two forms of this directive. With three arguments, it applies specifically to a filter-name and a provider-name for that filter. With two arguments it applies to a filter-name whenever the filter runs any provider. proto-flags is one or more of change=yes The filter changes the content, including possibly the content length change=1:1 The filter changes the content, but will not change the content length byteranges=no The filter cannot work on byteranges and requires complete input proxy=no The filter should not run in a proxy context proxy=transform The filter transforms the response in a manner incompatible with the HTTP Cache-Control: no-transform header. cache=no The filter renders the output uncacheable (eg by introducing randomised content changes) the change=1:1 says The filter changes the content, but will not change the content length, and we config our apache like this ErrorLog "/var/log/apache2/error.log" FilterDeclare MYFILTER FilterProvider MYFILTER SUBSTITUTE "%{CONTENT_TYPE} >= 'text/html'" FilterProvider MYFILTER SUBSTITUTE "%{CONTENT_TYPE} >= 'text/plain'" FilterProvider MYFILTER SUBSTITUTE "%{CONTENT_TYPE} >= 'application/json'" FilterProvider MYFILTER SUBSTITUTE "%{CONTENT_TYPE} >= 'application/xhtml+xml'" <IfModule mod_proxy.c> ProxyRequests On ProxyVia On NoProxy localhost ProxyBadHeader Ignore ProxyPreserveHost On FilterChain MYFILTER FilterTrace MYFILTER 1 FilterProtocol MYFILTER SUBSTITUTE change=1:1 Substitute "s|27.24.140|49.24.141|ni" RequestHeader unset Accept-Encoding </IfModule> But, as we test the apache module filter as add FilterProtocol MYFILTER SUBSTITUTE change=1:1 He also delete the content-length header. I don't know why. Or what i leave out?