Score:0

Apache directory listing: Permission denied

jp flag

So, I want to achieve something which should be easy: I want my Apache webserver to deliver its automatically generated directory listing since it is about statics HTML and PDF files.

However, I always receive an HTTP 403 response.

The error log says:

AH01276: Cannot serve directory /var/www/html/my-website/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive

And this is the output of ls -l /var/www/html/my-website:

drwxr-xr-x. 18 root root 4096 Jul  5 10:06 /var/www/html/my-website

And from getfacl /var/www/html/my-website:

getfacl: Removing leading '/' from absolute path names
# file: var/www/html/my-website
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

This is, stripped down to the relevant aspects, the virtual host configuration section:

<VirtualHost 192.168.1.2:80>
    ServerName my-website.local
    AddDefaultCharset iso-8859-1
    DirectoryIndex index.php index.html index.htm
    Alias / /var/www/html/my-website/
    DocumentRoot /var/www/html/my-website/
    <Directory /var/www/html/my-website/>
        AllowOverride none
        Options +Indexes
    </Directory>
</VirtualHost>

So, since o+rx is set, I expect it to be readable. What else am I missing?

faizan avatar
in flag
would it be possible to paste the relevant section of Apache config? The error you shared complains about a missing "DirectoryIndex" section (which is a file that Apache looks by default when it traverse a particular directory)
Score:0
jp flag

So, I can answer the question on my own, now. I post this answer here in case someone else stumbles over the same problem before spending 4 hours with it.

If the virtual configuration is correct, then probably a global configuration is not.

In this case, there was another configuration file named welcome.conf in place, obviously a default file from CentOS, which prevented the directory index from being delivered. The intention of this configuration file is to load the welcome page instead of listing a directory. The context of this configuration file is global.

Score:0
gb flag

You probably have

Options -Indexes

Somewhere related to my-website definition.

Change it to

Options +Indexes

And reload/restart/refresh.

Otherwise check for Selinux contexts with:

# ls -la --context /var/www/html/my-website
# chcon -R system_u:object_r:httpd_sys_content_t /var/www/html/my-website/
rexkogitans avatar
jp flag
I edited my question to contain the config.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.