install_httpd-2.4.sh: add configuration for compression delivery.
This commit is contained in:
		| @@ -3736,6 +3736,71 @@ else | |||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ## - Add configuration for custom log format file: 000-deflate.conf | ||||||
|  | ## - | ||||||
|  | echo "## - Add configuration to enable compression: 000-deflate.conf.." >> ${_logdir}/main.log | ||||||
|  | echo "## -" >> ${_logdir}/main.log | ||||||
|  | echo "" | ||||||
|  | echononl "\tAdd configuration to enable compression: 000-deflate.conf.." | ||||||
|  | cat << EOF > ${PREFIX}/conf/vhosts/000-deflate.conf | ||||||
|  | # --- | ||||||
|  | # - Enable output compression | ||||||
|  | # --- | ||||||
|  |  | ||||||
|  | <IfModule mod_headers.c> | ||||||
|  |    # Serve gzip compressed CSS and JS files if they exist | ||||||
|  |    # and the client accepts gzip. | ||||||
|  |    RewriteCond "%{HTTP:Accept-encoding}" "gzip" | ||||||
|  |    RewriteCond "%{REQUEST_FILENAME}\.gz" -s | ||||||
|  |    RewriteRule "^(.*)\.(css|js)" "\$1\.\$2\.gz" [QSA] | ||||||
|  |  | ||||||
|  |  | ||||||
|  |    # Serve correct content types, and prevent mod_deflate double gzip. | ||||||
|  |    RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1] | ||||||
|  |    RewriteRule "\.js\.gz$"  "-" [T=text/javascript,E=no-gzip:1] | ||||||
|  |  | ||||||
|  |  | ||||||
|  |    <FilesMatch "(\.js\.gz|\.css\.gz)$"> | ||||||
|  |       # Serve correct encoding type. | ||||||
|  |       Header append Content-Encoding gzip | ||||||
|  |  | ||||||
|  |       # Force proxies to cache gzipped & | ||||||
|  |       # non-gzipped css/js files separately. | ||||||
|  |       Header append Vary Accept-Encoding | ||||||
|  |    </FilesMatch> | ||||||
|  | </IfModule> | ||||||
|  |  | ||||||
|  | <IfModule mod_deflate.c> | ||||||
|  |  | ||||||
|  |    SetOutputFilter DEFLATE | ||||||
|  |  | ||||||
|  |    # You can't compress what is already compressed | ||||||
|  |    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary | ||||||
|  |    SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary | ||||||
|  |    SetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)\$ no-gzip dont-vary | ||||||
|  |    SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary | ||||||
|  |  | ||||||
|  | </IfModule> | ||||||
|  |  | ||||||
|  | <IfModule mod_deflate.c> | ||||||
|  |  | ||||||
|  |    DeflateFilterNote Input instream | ||||||
|  |    DeflateFilterNote Output outstream | ||||||
|  |    DeflateFilterNote Ratio ratio | ||||||
|  |    LogFormat '%v "%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate | ||||||
|  |  | ||||||
|  | </IfModule> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | EOF | ||||||
|  | if [ "$?" = "0" ]; then | ||||||
|  |    echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    warn "Adding config file 000-deflate.conf failed." | ||||||
|  | fi | ||||||
|  |  | ||||||
|  |  | ||||||
| ## - Add configuration for custom log format file: 000-logformat.conf | ## - Add configuration for custom log format file: 000-logformat.conf | ||||||
| ## - | ## - | ||||||
| echo "## - Add configuration for custom log format file: 000-logformat.conf.." >> ${_logdir}/main.log | echo "## - Add configuration for custom log format file: 000-logformat.conf.." >> ${_logdir}/main.log | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user