Score:0

Disallow access to all files except a alias in Apache 2.4

ru flag

I have a Debian 11 web server that is setup with the Matomo analytics PHP software. In the site's configuration I have these lines:

<Files "*">
    Require ip 192.168.0.0/24
</Files>

<FilesMatch "(^piwik\.(php|js)|^matomo\.(php|js)|^container_.*\.js|robots\.txt|optOut.js|favicon\.ico)">
    Require all granted
</FilesMatch>

Alias "/csp" "/www/vhosts/csp"
<Directory /www/vhosts/csp>
    DirectoryIndex index.php
    Require all granted
</Directory>

This is just a snippet. I also have a alias (/csp) with a few PHP files for a specific job. My problem is that I cannot access this alias outside the allowed IP range (192.168.0.0/24), although I have (in theory) added the directives for this (Require all granted) in the last Directory section. The /www/vhosts/csp directory resides outside Matomo's directory (thus, the Alias).

Inside the 192.168.0.0/24 network everything is fine. Accessing the /csp alias outside the network is not allowed (Forbidden because of client configuration).

How can I allow any host to access the /csp alias? Commenting out the first Files directive allows access to /csp, but is not what I wan (I don't want the other Matomo files to be accessible from any host).

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.