Red Hat Bugzilla – Bug 1015268
configtest does not fail if RewriteLog directive points to non-existent directory
Last modified: 2014-10-27 12:09:12 EDT
Description of problem:
'service httpd configtest' returns successfully with 'Syntax OK' if the mod_rewrite RewriteLog directive is used and points to a directory that does not exist. However, Apache fails to start (service httpd start/restart) with this error in the configuration and logs "[error] (2)No such file or directory: mod_rewrite: could not open RewriteLog file /invalid/directory/rewrite.log"
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Add a RewriteLog directive referencing an invalid directory, to an Apache configuration file:
2. Run 'service httpd configtest'. It will not detect an error and returns 'Syntax OK'
3. Restart Apache, 'service httpd restart'
4. Apache fails to start and logs a "No such file or directory" error in the error_log
'service httpd configtest' returns 'Syntax OK'
'service httpd configtest' should return an error
Thanks for contacting us.
"configtest" aims to check whether the configuration file is syntactically valid, and does not guarantee the server will start up.
I am generally reluctant to try adding such validation features because it is impossible in many cases to guard against false positives. Is there a particular problem you are trying to solve here?
I am using puppet to automate the management of some Apache config files. When a config file changes, puppet is set up to restart Apache, but I also run a configtest first to make sure Apache will restart OK.
/sbin/service httpd configtest && /sbin/service httpd graceful
I expect configtest to catch any errors that would cause Apache to fail to start.
Another way of looking at this problem is whether mod_rewrite should cause Apache to fail if it encounters an invalid path in a RewriteLog directive. Could mod_rewrite log the error, but allow Apache to continue to load?
Looking again: there's actually not a good place to hook in such a feature in 2.2 unfortunately.
In 2.4 there is no RewriteLog directive any more, since we have fine-grained error log control. But we do have a new hook which allows more sophisticated validation of directives, and ErrorLog does have a specific check for directory existence.
So probably an unsatisfactory answer, sorry, but "upgrade to RHEL 7" is probably the best answer we have here.