Раздел 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 Пункт 119. Apache Module mod_brotli
SummaryThe Sample ConfigurationsCompression and TLSSome web applications are vulnerable to an information disclosure attack when a TLS connection carries compressed data. For more information, review the details of the "BREACH" family of attacks. This is a simple configuration that compresses common text-based content types. Compress only a few typesAddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript Enabling CompressionCompression and TLSSome web applications are vulnerable to an information disclosure attack when a TLS connection carries compressed data. For more information, review the details of the "BREACH" family of attacks. Output CompressionCompression is implemented by the SetOutputFilter BROTLI_COMPRESS SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-brotli If you want to restrict the compression to particular MIME types
in general, you may use the <Directory "/your-server-root/manual"> AddOutputFilterByType BROTLI_COMPRESS text/html </Directory> NoteThe BROTLI_COMPRESS filter is always inserted after RESOURCE
filters like PHP or SSI. It never touches internal subrequests.
NoteThere is an environment variable no-brotli ,
set via SetEnv , which
will disable brotli compression for a particular request, even if
it is supported by the client.
Dealing with proxy serversThe If you use some special exclusions dependent
on, for example, the Header append Vary User-Agent If your decision about compression depends on other information
than request headers (e.g. HTTP version), you have to set the
ExampleHeader set Vary * Serving pre-compressed contentSince <IfModule mod_headers.c> # Serve brotli compressed CSS files if they exist # and the client accepts brotli. RewriteCond "%{HTTP:Accept-encoding}" "br" RewriteCond "%{REQUEST_FILENAME}\.br" "-s" RewriteRule "^(.*)\.css" "$1\.css\.br" [QSA] # Serve brotli compressed JS files if they exist # and the client accepts brotli. RewriteCond "%{HTTP:Accept-encoding}" "br" RewriteCond "%{REQUEST_FILENAME}\.br" "-s" RewriteRule "^(.*)\.js" "$1\.js\.br" [QSA] # Serve correct content types, and prevent double compression. RewriteRule "\.css\.br$" "-" [T=text/css,E=no-brotli:1] RewriteRule "\.js\.br$" "-" [T=text/javascript,E=no-brotli:1] <FilesMatch "(\.js\.br|\.css\.br)$"> # Serve correct encoding type. Header append Content-Encoding br # Force proxies to cache brotli & # non-brotli css/js files separately. Header append Vary Accept-Encoding </FilesMatch> </IfModule> BrotliAlterETag Directive
The
BrotliCompressionMaxInputBlock Directive
The BrotliCompressionQuality Directive
The BrotliCompressionWindow Directive
The BrotliFilterNote Directive
The ExampleBrotliFilterNote ratio LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' brotli CustomLog "logs/brotli_log" brotli If you want to extract more accurate values from your logs, you can use the type argument to specify the type of data left as a note for logging. type can be one of:
Thus you may log it this way: Accurate LoggingBrotliFilterNote Input instream BrotliFilterNote Output outstream BrotliFilterNote Ratio ratio LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' brotli CustomLog "logs/brotli_log" brotli See also
Пункты: 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 |
![]() |