-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: API to check if domain is valid (for on-demand HTTPS in Caddy) #25
Comments
@papascott -- thanks for this RFC. I understand what's going on, I think -- first a question -- Does the name of the call have to be /check? It's kind of a generic name from the PP point of view. Check what? Also I think i'm going to look for a way to make sure the request is coming from the local host. Dave |
@scripting The call can be called anything you want, no need to use '/check'. And checking for localhost sounds like a very good idea! |
OK, I have it working.
Returns local.karass.co because it is one of the domains my local copy of PagePark serves. The new version of PP is released. Here's the new call. Please review, and let me know if it looks right. There's a change note for this work. |
I updated my test PagePark server and Caddy configuration to the new call, everything seems to work! 👍 |
Caddy is a web server that can do automatic HTTPS, automatically provisioning TLS certificates (from Let's Encrypt) for a domain and keeping them renewed. This already works with PagePark if the domains are manually configured in Caddy. However, Caddy can also request certificates on demand for domains not specified in the configuration. This would be handy for PagePark so HTTPS would automatically work when domains are added.
For security reasons Caddy should only provision domains that are valid for the server, otherwise the server is open to attack. Caddy checks for valid domains by "asking" an HTTP endpoint if it has permission to obtain a certificate for a certain domain. Once it has a certificate it will never "ask" again and renew the certificate silently.
I am proposing a localhost endpoint '/check' in PagePark that would answer this request. It takes a 'domain' query parameter. It returns 200 if the domain is configured in PagePark and 400 if not. This initial version handles both regular domains and wildcard domains in PagePark. It does not handle the "default" directory. Additional configuration would be needed to handle "default" domains.
The endpoint would be inserted into the case statement currently at line 1050 of pagepark.js:
Here is a sample "Caddyfile" (Caddy configuration file) that will answer all HTTPS requests ("asking" PagePark if it needs to obtain a certificate) and redirects all HTTP requests to HTTPS (the default):
Caddy provides packages for Ubuntu and can easily be installed on Digital Ocean.
The text was updated successfully, but these errors were encountered: