【问题标题】:mod_filter: Why does a SUBSTITUTE not work for certain URLs?mod_filter:为什么 SUBSTITUTE 不适用于某些 URL?
【发布时间】:2013-08-12 08:38:22
【问题描述】:

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

如何解决这个问题?

【问题讨论】:

    标签: apache mod-filter


    【解决方案1】:

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

    Header set Accept-Ranges "none"
    

    将使过滤器工作。

    【讨论】:

      猜你喜欢
      • 2012-10-28
      • 2015-12-10
      • 1970-01-01
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      相关资源
      最近更新 更多