Add RewriteEngine on directive also in post (#10232)

Fixes
https://github.com/certbot/certbot/issues/9835#issuecomment-2717096178,
where our `RewriteEngine on` directive inserted at the beginning of a
virtualhost was overridden a `RewriteEngine Off` directive later. This
PR does the easy thing of placing `RewriteEngine on` in our
post-insert.
This commit is contained in:
ohemorange 2025-03-17 13:02:10 -07:00 committed by GitHub
parent 8a6138856f
commit aa005f20fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -24,10 +24,10 @@ class ApacheHttp01(common.ChallengePerformer):
"""Class that performs HTTP-01 challenges within the Apache configurator."""
CONFIG_TEMPLATE24_PRE = """\
RewriteEngine on
RewriteRule ^/\\.well-known/acme-challenge/([A-Za-z0-9-_=]+)$ {0}/$1 [END]
"""
CONFIG_TEMPLATE24_POST = """\
RewriteEngine on
<Directory {0}>
Require all granted
</Directory>

View file

@ -209,7 +209,7 @@ class ApacheHttp01Test(util.ApacheTest):
with open(self.http.challenge_conf_post) as f:
post_conf_contents = f.read()
assert "RewriteEngine on" in pre_conf_contents
assert "RewriteEngine on" in post_conf_contents
assert "RewriteRule" in pre_conf_contents
assert self.http.challenge_dir in post_conf_contents

View file

@ -17,7 +17,9 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
### Fixed
*
* Moved `RewriteEngine on` directive added during apache http01 authentication
to the end of the virtual host, so that it overwrites any `RewriteEngine off`
directives that already exist and allows redirection to the challenge URL.
More details about these changes can be found on our GitHub repo.