DanielDent / docker-nginx-ssl-proxy

SSL Front-End Proxy With Automatic Free Certificate Management
https://hub.docker.com/r/danieldent/nginx-ssl-proxy/
Other
204 stars 68 forks source link

PreCheck Domain to avoid Let's Encrypt Rate Limits #23

Closed claytondaley closed 5 years ago

claytondaley commented 5 years ago

This is an initial effort to resolve #19 by ensuring that something is responding at the requested domain before proceeding to the Let's Encrypt step. This should reduce the odds of tripping rate limits while the DNS is improperly configured (e.g. when new AWS ECS tasks are assigned arbitrary IP addresses).

I've tested this in ECS and it's working. If a server cannot connect to itself at its own DNS entry, this check will forever fail. It may make sense to add support for an environment variable like SKIP_DNS_CHECK that may be called to skip this section (but my bash-fu is weak so I did not attempt it).

DanielDent commented 5 years ago

Hi Clayton -- thanks for the pull request. I agree there is value in having a safety check like this. I thought that doing this was built into the ACME client -- perhaps it used to be (at some point in the history of this project, the ACME client got swapped out for a different one). I've had this on my agenda to address at some point, but haven't yet made the time.

I think a much better safety would be to somewhat emulate the acme protocol by placing a file with random contents at a random location under the ACME .well-known path -- and while we are at it, I'd see value in ensuring that multiple consecutive checks pass, to help mitigate issues where e.g. one load balancer is correctly configured, but other load balancers in the rotation have not yet caught up to the working configuration.

My core concern -- there's lots of misconfiguration situations where you'll get a valid 200 response from a domain's root, but it isn't actually routed to this container. Likewise / could be returning a 500 response, but the correct behaviour may still be to issue get the SSL certificate issued regardless.

claytondaley commented 5 years ago

Agree with everything you say. I'm +100 for improvement. Unfortunately, my bash-fu is poor so I wanted to keep my change simple but useful. This addresses the most extreme case (system inaccessible).

DanielDent commented 5 years ago

Thanks Clayton -- I've merged this for now but re-opened #19 to keep track of this