Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fuss:apache [2017/02/22 18:30] – external edit 127.0.0.1fuss:apache [2022/09/17 22:36] (current) – [Globally Enable brotli Compression] office
Line 360: Line 360:
 &\approx& 71  &\approx& 71 
 \end{eqnarray*} \end{eqnarray*}
 +
 +====== Implementing a Global and Consistent Directory Index Style ======
 +
 +The following setup implements a global and consistent directory index style that can be used for multiple virtual hosts just by adding an include to any ''Directory'' stanza within a virtual host configuration.
 +
 +<ditaa>
 ++ /
 +|
 ++---+ /etc/apache2/
 +|         +
 +|         |
 +|         +---+ conf-available/
 +|                   +
 +|                   |
 +|                   +---+ fancyindex.conf
 +|         
 +|         +---+ includes/
 +|                 +
 +|                 |
 +|                 +---+ fancyindex.conf
 +|         |
 +|         +---+ sites-available/
 +|                    +
 +|                    |
 +|                    +---+ vhost.conf
 +|          
 ++---+ /var/www/
 +         +
 +         |
 +         +---+ .fancyindex.css      
 +</ditaa>
 +
 +where:
 +  * ''/etc/apache2/conf-available/fancyindex.conf'' contains:
 +<code>
 +Alias "/fancyindex.css" "/var/www/.fancyindex.css
 +</code>
 +  * ''/etc/apache2/includes/fancyindex.conf'' contains:
 +<code>
 +IndexOptions +Charset=UTF-8
 +IndexOptions +TrackModified
 +IndexOptions +Charset=UTF-8
 +IndexOptions +FoldersFirst
 +IndexOptions +NameWidth=*
 +IndexOptions +FancyIndexing
 +IndexOptions +HTMLTable
 +IndexOptions +SuppressDescription
 +IndexIgnore favicon.ico
 +IndexIgnore auth*
 +IndexIgnore include*
 +IndexIgnore css*
 +IndexIgnore share*
 +IndexIgnore upload*
 +IndexIgnore incoming*
 +IndexStyleSheet "/fancyindex.css"
 +Options +Indexes
 +</code>
 +  * ''/etc/apache2/sites-available/vhost.conf'' is a virtual host configuration where the indexing can be turned on within any ''Directory'' stanza just by including ''/etc/apache2/includes/fancyindex.conf'', ie enabling directory indexing for the directory named ''path'' relative to the root of the virtual host:
 +<code>
 +    <Directory /path>
 +        include "includes/fancyindex.conf"
 +    </Directory>
 +</code>
 +  * ''/var/www/.fancyindex.css'' contains the following:
 +<code>
 +* {
 +    font-family: monospace;
 +}
 +</code>
 +and is responsible for setting the CSS for the rendered index page.
 +
 +<WRAP info>
 +''IndexStyleSheet'' takes an URL relative to the virtual host document root such that the aliasing performed within ''/etc/apache2/conf-available/fancyindex.conf'' redirects the requests to the default virtual host where the ''/var/www/.fancyindex.css'' file is placed. It ain't pretty, but it works; at least short of changing ''IndexStyleSheet'' itself! 
 +</WRAP>
 +
 +Perhaps a good reason for preferring this setup to using ''AllowOverride'' and ''.htaccess'' files is that the style of the directory index is generated by Apache itself rather than the website such that one can avoid mixing data with code. Furthermore, given multiple virtual hosts with the same owner, a consistent style may be preferred and with a centralized way of batch-changing all directory indexes.
 +
 +====== Globally Enable brotli Compression ======
 +
 +On Debian, to enable brotli compression, the Apache module must first be installed by issuing the command:
 +<code bash>
 +apt-get install brotli
 +</code>
 +
 +and then the Apache module must be enabled by issuing the command:
 +<code bash>
 +a2enmod brotli
 +</code>
 +
 +Lastly, create the file ''/etc/apache2/conf-available/brotli.conf'' with the following contents:
 +<code>
 +<IfModule mod_brotli.c>
 +    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript
 +</IfModule>
 +</code>
 +
 +The purpose of this file is to instruct the brotli Apache module to compress certain resources, namely textual content as well as javascript with the brotli compressor.
 +
 +Finally, enable the configuration file by issuing the command:
 +<code bash>
 +a2enconf brotli
 +</code>
 +
 +and reload the Apache configuration:
 +<code bash>
 +systemctl apache2 reload
 +</code>
 +
 +The brotli compressor should now be enabled and will globally compress content as it is transferred from the Apache server.
 +
 +Note that an alternative configuration is to add the contents of the file ''/etc/apache2/conf-available/brotli.conf'' to a virtual host definition in order to only compress some websites.
 +
 +
 +

fuss/apache.txt · Last modified: 2022/09/17 22:36 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.