mod_filter:为什么SUBSTITUTE不适用于某些URL?

时间:2013-08-10 15:08:42

标签: apache mod-filter

我将 mod-proxy mod-filter 结合使用,使内部服务器(nginx)可以从网络外部访问。我的过滤器配置是:

SetEnv filter-errordocs # necessary to process requests which don't have HTTP 200 OK
FilterDeclare ghe
FilterProvider gzinflate INFLATE resp=Content-Encoding $gzip
FilterProvider ghe SUBSTITUTE resp=Content-Type $text/
FilterProvider gzdeflate DEFLATE Content-Type $text/
FilterChain +gzinflate +ghe +gzdeflate
FilterTrace ghe 1

这适用于HTML页面,curl -I http://internal/url给出了类似的内容:

HTTP/1.1 200 OK
Server: server.com
Date: Sat, 10 Aug 2013 14:55:25 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: no-cache, no-store
X-Frame-Options: deny
Set-Cookie: logged_in=no; domain=.192.168.120.128; path=/; expires=Wed, 10-Aug-2033 14:55:25 GMT; HttpOnly
Set-Cookie: _fi_sess=xyz HttpOnly
X-Runtime: 19
ETag: "zyx"
Content-Length: 5928

但是,访问例如,它不起作用 css 文件curl -I http://internal/url.css提供的内容如下:

HTTP/1.1 200 OK
Server: server.com
Date: Sat, 10 Aug 2013 14:55:31 GMT
Content-Type: text/css
Content-Length: 269455
Last-Modified: Fri, 09 Aug 2013 14:23:05 GMT
Connection: keep-alive
Accept-Ranges: bytes

问题在Apache的错误日志(使用调试LogLevel)中以某种方式可见。对于应用过滤器的网址,我看到类似的内容(不确定EOS - 部分是否是相同的请求):

[Sat Aug 10 16:44:27 2013] [debug] mod_headers.c(756): headers: ap_headers_output_filter()
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(117): [client 192.168.93.201] ghe
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(122): [client 192.168.93.201] ghe: type: HEAP, length: 8096
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(117): [client 192.168.93.201] ghe
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(122): [client 192.168.93.201] ghe: type: HEAP, length: 8096
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(117): [client 192.168.93.201] ghe
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(122): [client 192.168.93.201] ghe: type: HEAP, length: 1097
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(122): [client 192.168.93.201] ghe: type: EOS, length: 0
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(117): [client 192.168.93.201] ghe
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(122): [client 192.168.93.201] ghe: type: EOS, length: 0

对于未应用过滤器的网址,我只看到如下内容:

[Sat Aug 10 16:44:27 2013] [debug] mod_headers.c(756): headers: ap_headers_output_filter()
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(117): [client 192.168.93.201] ghe
[Sat Aug 10 16:44:27 2013] [debug] mod_filter.c(122): [client 192.168.93.201] ghe: type: EOS, length: 0

所以,只有EOS,但没有HEAP,如果这确实意味着什么。

如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

SUBSTITUTE过滤器可能不适用于Accept-Ranges: bytes。使用 mod-header 并将以下行添加到Apache配置文件中:

Header set Accept-Ranges "none"

将使过滤器正常工作。