有没有Apache 2.2和内容filter(也许mod_proxy)的错误?

我在RHEL 6(实际上是Scientific Linux 6.4)上运行Apache 2.2.15-29,我试图设置一个带有内容重写的反向代理,以便代理网页上的所有链接都被重写,以引用代理主机。 我遇到了一些重写内容的问题,我想知道这是一个错误,还是我做错了什么(如果适用的话,如何做到这一点)。

我将内部主机( internal.example.com/foo )上的子目录代理到外部主机( external.example.com )的根目录上。 我需要重写HTML,CSS和Javascript内容来修复所有的URL。 我还在外部主机上托pipe了一些本地内容,我不认为这是一个问题,但我在这里提到完整性。

我的httpd.conf看起来大致是这样的:

 <VirtualHost *:80> ServerName external.example.com ServerAlias example.com # Serve all local content directly, reverse-proxy all unknown URIs. RewriteEngine On RewriteRule ^(/(index.html?)?)?$ http://internal.example.com/foo/ [P] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d RewriteRule ^.*$ - [L] RewriteRule ^/~ - [L] RewriteRule ^(.*)$ http://internal.example.com$1 [P] # Standard header rewriting. ProxyPassReverse / http://internal.example.com/foo/ ProxyPassReverseCookieDomain internal.example.com external.example.com ProxyPassReverseCookiePath /foo/ / # Strip any Accept-Encoding: headers from the client so we can process the pages # as plain text. RequestHeader unset Accept-Encoding # Use mod_proxy_html to fix URLs in text/html content. ProxyHTMLEnable On ProxyHTMLURLMap http://internal.example.com/foo/ / ProxyHTMLURLMap http://internal.example.com/foo / ProxyHTMLURLMap /foo/ / ## Use mod_substitute to fix URLs in CSS and Javascript #<Location /> # AddOutputFilterByType SUBSTITUTE text/css # AddOutputFilterByType SUBSTITUTE text/javascript # Substitute "s|http://internal.example.com/foo/|/|nq" #</Location> # Use mod_ext_filter to fix URLs in CSS and Javascript ExtFilterDefine fixurlcss mode=output intype=text/css cmd="/bin/sed -rf /etc/httpd/fixurls" ExtFilterDefine fixurljs mode=output intype=text/javascript cmd="/bin/sed -rf /etc/httpd/fixurls" <Location /> SetOutputFilter fixurlcss;fixurljs </Location> </VirtualHost> 

文本/ HTML重写工作得很好。 当我使用mod_substitute或mod_ext_filter时,外部服务器以Transfer-Encoding: chunked发送页面Transfer-Encoding: chunked ,发送所有数据,然后closures连接而不发送最后的零长度块。 有些HTTP客户端对此不满意。 (Chrome不会处理以这种方式发送的任何内容,例如,所以页面不会将CSS应用于它们。)

以下是一个示例wget会话:

 $ wget -O /dev/null -S http://external.example.com/include/jquery.js --2013-11-01 11:36:36-- http://external.example.com/include/jquery.js Resolving external.example.com (external.example.com)... 192.168.0.1 Connecting to external.example.com (external.example.com)|192.168.0.1|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 200 OK Date: Fri, 01 Nov 2013 15:36:36 GMT Server: Apache Last-Modified: Tue, 29 Oct 2013 13:09:10 GMT ETag: "1d60026-187b8-4e9e0ec273e35" Accept-Ranges: bytes Vary: Accept-Encoding X-UA-Compatible: IE=edge,chrome=1 Content-Type: text/javascript;charset=utf-8 Connection: close Transfer-Encoding: chunked Length: unspecified [text/javascript] Saving to: `/dev/null' [ <=> ] 100,280 --.-K/s in 0.005s 2013-11-01 11:36:37 (19.8 MB/s) - Read error at byte 100280 (Success).Retrying. --2013-11-01 11:36:38-- (try: 2) http://external.example.com/include/jquery.js Connecting to external.example.com (external.example.com)|192.168.0.1|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 416 Requested Range Not Satisfiable Date: Fri, 01 Nov 2013 15:36:38 GMT Server: Apache Vary: Accept-Encoding Content-Type: text/html;charset=utf-8 Content-Length: 260 Connection: close The file is already fully retrieved; nothing to do. 

难道我做错了什么? 我是否遇到某种Apache错误? 我需要做些什么才能使它工作? (请注意,我更喜欢在RHEL-6打包的RPM中运行的解决scheme,并且升级到Apache 2.4将是最后的手段,因为目前我们在这个系统上有大量基于2.2的基础架构。)

事实certificate,这是一个在mod_proxy_html中的错误: https ://www.apachelounge.com/viewtopic.php ? t = 3552和http://marc.info/?l=apache-httpd-users&m=127237168923132&w=2 。 我在第一个链接中应用了代码更改,分块的内容开始正常工作。