iTranslated by AI
[Apache] Non-existent paths in Directory directives do not trigger syntax errors
What Happened
I wrote an Apache configuration file to apply IP restrictions to a specific directory of a web application.
I performed a syntax check using the httpd -t command, and since it returned Syntax OK, I reloaded the Apache configuration file.
To confirm that the settings were applied, I tried accessing it, but it was still accessible as usual.
Configuration Details
The following is an illustrative example of the content.
<VirtualHost xxx.xxx.xxx.xxx:443>
ServerName hoge.example.com
DocumentRoot /var/www/html/hoge.example.com/public
<Directory /var/www/html/hoeg.example.com/public>
Require ip yyy.yyy.yyy.yyy
</Directory>
# Omitting the rest
</VirtualHost>
The Reason Why the IP Restriction Wasn't Working
The path in the Directory directive was a non-existent path.
- <Directory /var/www/html/hoeg.example.com/public>
+ <Directory /var/www/html/hoge.example.com/public>
After correcting the path in the settings and reloading the configuration, the IP restriction started working.
It seems that httpd -t does not return an error even if the path in the Directory directive does not exist.
Since an error occurs if the DocumentRoot is incorrect, I assumed the same behavior for the Directory directive path, which is why it took me some time to find the cause.
Discussion