2011-03-08 20 views

Trả lời

4

Tôi đang sử dụng mod_filter cho substituing thay vì xì hơi, nhưng ý tưởng là như nhau. Đây là những gì làm việc cho tôi (tôi đang làm reverse proxy và viết lại url và liên kết):

LoadModule substitute_module modules/mod_substitute.so 
LoadModule filter_module modules/mod_filter.so 
FilterDeclare MYFILTER 
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $text/ 
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/xml 
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/json 
FilterProvider MYFILTER SUBSTITUTE resp=Content-Type $/javascript 
<Location /sial/> 
    ProxyPass  http://localhost:8300/ 
    ProxyPassReverse http://localhost:8300/ 
    ProxyPassReverseCookiePath//sial/ 
    FilterChain MYFILTER 
    Substitute "s|/tea_sial_v2|/sial/tea_sial_v2|inq" 
</Location> 
14

AddOutputFilterByType có những hạn chế nghiêm trọng trong httpd-2.2 vì thế nó được đánh dấu phản đối đó. Nhưng trong httpd-2.4, chỉ thị này đã được chuyển đến filter_module, đã sửa và không được chấp nhận.

Trong apache 2.2 bạn thay vì phải kích hoạt tính năng filter_moduledeflate_module và sử dụng:

# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI 
FilterDeclare gzip CONTENT_SET 

# "gzip" filter can change "Content-Length", can not be used with range requests 
FilterProtocol gzip change=yes;byteranges=no 

# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc. 
FilterProvider gzip DEFLATE resp=Content-Type $text/html 
FilterProvider gzip DEFLATE resp=Content-Type $text/css 
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript 
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript 
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript 

# Add "gzip" filter to the chain of filters 
FilterChain gzip 

deflate_module sẽ chỉ phân phối nội dung nén để trình duyệt thực hiện kê khai hỗ trợ cho gzip mã hóa trong yêu cầu tiêu đề.

+1

này đã giúp tôi bigtime. Chỉ cần một người đứng đầu trên FilterProvider: https://github.com/h5bp/html5-boilerplate/issues/1012 – cgp

+0

Trong Centos filter_module không được kích hoạt theo mặc định. Cần phải được uncommented. –

+0

Điều này khiến ETags bị thiếu một cách ngẫu nhiên từ các phản hồi gzipped. – Timothy003

2

Nó trở nên không được chấp nhận trong Apache 2.3.7, vì nó đã được di chuyển/tích hợp vào mod_filter. Vì vậy, những gì tôi đã có trong:

Thay vì:

<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/css 
</IfModule> 

sử dụng:

<IfModule mod_filter.c> 
    AddOutputFilterByType DEFLATE text/css 
</IfModule> 
Các vấn đề liên quan