Раздел 10. Apache modules Пункты: 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 163 164 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 203 204 205 206 207 208 209 210 211 212 213 RU EN Пункт 141. Apache Module mod_ext_filter
Summary
Even when the performance characteristics are not suitable
for production use, ExamplesGenerating HTML from some other type of response# mod_ext_filter directive to define a filter # to HTML-ize text/c files using the external # program /usr/bin/enscript, with the type of # the result set to text/html ExtFilterDefine c-to-html mode=output \ intype=text/c outtype=text/html \ cmd="/usr/bin/enscript --color -W html -Ec -o - -" <Directory "/export/home/trawick/apacheinst/htdocs/c"> # core directive to cause the new filter to # be run on output SetOutputFilter c-to-html # mod_mime directive to set the type of .c # files to text/c AddType text/c .c </Directory> Implementing a content encoding filterNote: this gzip example is just for the purposes of illustration.
Please refer to # mod_ext_filter directive to define the external filter ExtFilterDefine gzip mode=output cmd=/bin/gzip <Location "/gzipped"> # core directive to cause the gzip filter to be # run on output SetOutputFilter gzip # mod_headers directive to add # "Content-Encoding: gzip" header field Header set Content-Encoding gzip </Location> Slowing down the server# mod_ext_filter directive to define a filter # which runs everything through cat; cat doesn't # modify anything; it just introduces extra pathlength # and consumes more resources ExtFilterDefine slowdown mode=output cmd=/bin/cat \ preservescontentlength <Location "/"> # core directive to cause the slowdown filter to # be run several times on output # SetOutputFilter slowdown;slowdown;slowdown </Location> Using sed to replace text in the response# mod_ext_filter directive to define a filter which # replaces text in the response # ExtFilterDefine fixtext mode=output intype=text/html \ cmd="/bin/sed s/verdana/arial/g" <Location "/"> # core directive to cause the fixtext filter to # be run on output SetOutputFilter fixtext </Location> You can do the same thing using Tracing another filter# Trace the data read and written by mod_deflate # for a particular client (IP 192.168.1.31) # experiencing compression problems. # This filter will trace what goes into mod_deflate. ExtFilterDefine tracebefore \ cmd="/bin/tracefilter.pl /tmp/tracebefore" \ EnableEnv=trace_this_client # This filter will trace what goes after mod_deflate. # Note that without the ftype parameter, the default # filter type of AP_FTYPE_RESOURCE would cause the # filter to be placed *before* mod_deflate in the filter # chain. Giving it a numeric value slightly higher than # AP_FTYPE_CONTENT_SET will ensure that it is placed # after mod_deflate. ExtFilterDefine traceafter \ cmd="/bin/tracefilter.pl /tmp/traceafter" \ EnableEnv=trace_this_client ftype=21 <Directory "/usr/local/docs"> SetEnvIf Remote_Addr 192.168.1.31 trace_this_client SetOutputFilter tracebefore;deflate;traceafter </Directory> Here is the filter which traces the data:#!/usr/local/bin/perl -w use strict; open(SAVE, ">$ARGV[0]") or die "can't open $ARGV[0]: $?"; while (<STDIN>) { print SAVE $_; print $_; } close(SAVE); ExtFilterDefine Directive
The filtername specifies the name of the filter being
defined. This name can then be used in Subsequent parameters can appear in any order and define the
external command to run and certain other characteristics. The
only required parameter is
ExtFilterOptions Directive
The
ExtFilterOptions LogStderr Messages written to the filter's standard error will be stored in the Apache error log. Пункты: 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 163 164 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 203 204 205 206 207 208 209 210 211 212 213 |