Enable Let's Encrypt to transition http sites to https #565
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem. When the LE role runs for an existing http site, the site already has an Nginx conf in
sites-enabled/site.com.conf
with a server block that doesn't include a location block for the Acme Challenge. If the LE role happens to create/load thenginx-challenge-site.conf
, its server block will compete in sorting of the glob inclusion and either the Acme Challenge or the actual site won't be served till thenginx-challenge-site.conf
is disabled. This means that either the Acme Challenges will fail, or the regular site will be down for a moment.Proposed solution. This PR resolves the problem of competing server blocks by extending a strategy already in place. The already existing strategy is that when ssl is enabled, the http->https redirection section also loads the Acme Challenge location block so that LE cert renewals will pass challenge tests.
It seems relatively harmless to have the Acme Challenge location block there in the conf all the time. This PR adds the Acme Challenge location block to the non-ssl conf. As a result, when the LE role runs on an existing http site, it will use the site's existing conf (or create a new Acme Challenge conf if somehow there is no conf already). Either way, the Acme Challenge tests pass.
This creates a bit more crossover between the
letsencrypt
role and thewordpress-setup
role, but I'm not sure it can be avoided.The one context privileged to not have to deal with the extra Acme Challenges location block is what should be the most common: 1) ssl enabled and 2) no www redirect necessary.