2

我将mod-proxymod-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)。对于应用过滤器的 URL,我看到类似这样的内容(但不确定EOS-part 是否是同一个请求):

[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

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

[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,如果这确实意味着什么。

如何解决这个问题?

4

1 回答 1

2

SUBSTITUTE filter may not work with Accept-Ranges: bytes. Using mod-header and adding following line to the Apache configuration file:

Header set Accept-Ranges "none"

will make the filter work.

于 2013-08-11T11:43:21.143 回答