I'm having trouble getting Apache to regonize an Options directive inside a VirtualHost block. The following snippet is as simple as I can make it that will reproduce the error - the rest of the configuration is a stock Deiban Apache 2.4.
<VirtualHost *:80> ServerName example DocumentRoot /home/test/ #owner www-data:www-data Options +Indexes <Location /> Require all granted </Location> </VirtualHost> This will fail with a 403 Forbidden and the following line in the corresponding log:
[Sun Jun 26 15:06:30.378689 2016] [autoindex:error] [pid 15899:tid 140693629712128] [client 192.168.0.155:52850] AH01276: Cannot serve directory /home/test/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive However, placing the Options +Indexes directive inside the <Location /> container will fix it and the auto-generated index will be served.
I'd like to know why it must be placed inside <Location /> for it to work rather than just <VirtualHost>. The Apache 2.4 docs say that the Options directive can be placed in the following context[1]
Context: server config, virtual host, directory, .htaccess
So why is it not working inside VirtualHost?
Edit #1
Output of apachectl -S
AH00557: apache2: apr_sockaddr_info_get() failed for garnet AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:80 garnet.cat (/etc/apache2/sites-enabled/test.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex default: dir="/var/run/apache2/" mechanism=default Mutex watchdog-callback: using_defaults Mutex proxy: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33 Regarding other possible Options directives somewhere else in config files:
I couldn't find any. I used root@garnet:/etc/apache2# grep -P -Rni '\soptions\s' . to find occurrences of the Options directive in the config files. All matches were in comment strings or in unrelated <Directory> blocks. Regardless, doesn't the VirtualHost block override directives specified outside it?
<Location />directive somewhere in the config that hasOptions -Indexesin it.