How do i use apache filesystem & webspace containers?
-
First things first, let's explain what the difference between filesystem and webspace is:
Filesystem as it related to apache where you've installed your apache files, /usr/local/apache2
Webspace is what is viewed from your web server, e.g: /usr/local/apache2/htdocs/myweb/ that directory myweb will be https://example.org/myweb, although it is not always a one to one filesystem to webspace mapping as in the case of dynamically generated web pages via a database for example.
The <Directory> section, if a matching directory is found apply the directives. e.g: Apply indexes to the /var/web/dir1 and all files under it.
<Directory "/var/web/dir1"> Options +Indexes </Directory>
The <Files> sections is the same but matches any file name regardless of the directory it is in. e.g:
<Files "private.html"> Require all denied </Files>
You can combine the two sections above, for instance deny access to a file under any directory and sub-directory.
<Directory "/var/web/dir1"> <Files "private.html"> Require all denied </Files> </Directory>
The <Location> section, relates to webspace containers, e.g: The following code denies access to any URLs with the word private in it.
<LocationMatch "ˆ/private"> Require all denied </LocationMatch>
The <Location> section does not have to be associated with a part of the filesystem, e.g: The following calls the server-status apache handler
<Location "/server-status"> SetHandler server-status </Location>
Overlapping Webspace
There is an order in which sections apply directives to hierarchy of webspace areas.<Location> uses, a top, down approach, where as <Alias> & <ProxyPass>, use a bottom, up approach. see examples:
<Location "/foo"> </Location> <Location "/foo/bar"> </Location> Alias "/foo/bar" "/srv/www/uncommon/bar" Alias "/foo" "/srv/www/common/foo" ProxyPass "/special-area" "http://special.example.com" smax=5 max=10 ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid nofailover=On
© Lightnetics 2024