Skip to content

Support HTTPS for custom domains #2652

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

Closed
alex opened this issue Feb 19, 2017 · 45 comments
Closed

Support HTTPS for custom domains #2652

alex opened this issue Feb 19, 2017 · 45 comments
Labels
Improvement Minor improvement to code

Comments

@alex
Copy link
Contributor

alex commented Feb 19, 2017

It'd be great if RTD supported HTTPS when using a custom domain. Once upon a time this would have been difficult and expensive, however nowadays with SNI and Lets Encrypt I think this is possible -- providers like SquareSpace and Wordpress have demonstrated this.

Here's how it could work:

  • When a new custom domain is added, trigger an attempt to obtain a certificate, triggering the lets encrypt validation flow.
  • Redirect all /.well-known/* from all RTD sites to a special validation server
  • On the validation server, serve the correct value for the LE challenge for that domain
  • Obtain the certificate, and store it somewhere.
  • (Make sure to repeat every X days so certs don't expire!)
  • When a request comes in with SNI=foo.com, look up that cert and server it if it's a RTD site

Hopefully that makes sense!

@alex
Copy link
Contributor Author

alex commented Feb 19, 2017

Here's SquareSpace's write up of how they did it: https://engineering.squarespace.com/blog/2016/implementing-ssl-tls-for-all-squarespace-sites

@alex
Copy link
Contributor Author

alex commented Feb 19, 2017

@alex
Copy link
Contributor Author

alex commented Feb 19, 2017

And one more for good measure :-) https://www.digitalgov.gov/2016/09/07/lets-encrypt-those-cnames-shall-we/

@alex
Copy link
Contributor Author

alex commented Feb 19, 2017

Just occurred to me that Caddy (https://caddyserver.com/) can be used as an automatically-adding-tls-reverse-proxy.

@agjohnson
Copy link
Contributor

We've been wanting to add letsencrypt support for a while. We have an idea of how it would all come together, and this is on our list of features we'll implement as soon as it makes sense financially. We're hoping sometime in the first half of this year perhaps?

This will probably be an equal amount of effort on the code and on the operations side. We have too much logic built in to nginx currently, we wouldn't swap that out, but perhaps running a secondary service for /.well-known/ serving would be fine. There are a number of issues that we'd have to overcome operationally, such as how to keep our web cluster certs in sync, how nginx handles the certs, etc. These all have solutions, but the changes are still significant.

This all goes back to #328, but I think letsencrypt is the best way we have of solving this problem.

@alex
Copy link
Contributor Author

alex commented Feb 20, 2017 via email

@rmzelle
Copy link

rmzelle commented Mar 10, 2018

GitHub seems to be slowly rolling out HTTPS support for GitHub Pages, also using Let's Encrypt. See isaacs/github#156 (comment) and the rest of that thread.

Would love to see HTTPS support for RTD custom domains as well!

@rmzelle
Copy link

rmzelle commented May 2, 2018

(GitHub just announced official support for HTTPS for GitHub Pages served at custom domains. See https://twitter.com/github/status/991366832421523456)

@davidfischer
Copy link
Contributor

@rmzelle, this is on our roadmap. I see a 5 step roadmap toward HTTPS everywhere on docs sites on RTD. Here's an outline: #3282 (comment). Here's a PR for step 1: #3987.

If you are interested in getting involved, you can start by reviewing the PRs in this area starting with #3987 or if you want to work on this part (step 3 as I see it), that's fantastic! I am specifically very interested and actively working toward HTTPS everywhere on RTD but I will take all the help I can get.

@davidfischer
Copy link
Contributor

To give a small update here, I'm working with Cloudflare to make this a reality. If all goes well, I'd say it's 2 weeks out.

@davidfischer
Copy link
Contributor

I wouldn't quite call this "done" but as of today Cloudflare is issuing SSL certificates for custom domains hosted by us.

Our CNAME support has been around a long time so there are still a lot of domains pointing to readthedocs.org instead of readthedocs.io. I'm working through some issues but eventually I hope that I can issue certificates for domains with the old setup. In the meantime, pointing the CNAME to readthedocs.io should do it.

There are also folks hosting docs at top level domains (eg. cryptography.io) and I haven't quite worked through how that will work.

@alex
Copy link
Contributor Author

alex commented Jul 17, 2018 via email

@davidfischer
Copy link
Contributor

cryptography.io's DNS points at a reverse proxy we run, so that's may
be a distinct case.

True. I used it as an example and it wasn't an ideal example.

@davidfischer davidfischer removed the Needed: design decision A core team decision is required label Jul 17, 2018
@desertkun
Copy link

Apparently having a CNAME to readthedocs.io now results in a Error 1014: CNAME Cross-User Banned if the user itself uses cloudflare too.

I've been using cloudflare to http proxy to readthedocs.io to have custom domain with HTTPS, and because apparently it's now user cloudflare too, my domain is banned.

@stsewd
Copy link
Member

stsewd commented Jul 18, 2018

@desertkun please see #4395

@begriffs
Copy link

I wouldn't quite call this "done" but as of today Cloudflare is issuing SSL certificates for custom domains hosted by us.

Do you have a rough estimate for when http->https redirection will be enabled?

@rmzelle
Copy link

rmzelle commented Jul 19, 2018

In the meantime, pointing the CNAME to readthedocs.io should do it.

It looks like this is the case for our site:

$ dig docs.citationstyles.org CNAME
...
docs.citationstyles.org. 6745	IN	CNAME	readthedocs.io

However, Firefox reports for https://docs.citationstyles.org/en/stable/:

docs.citationstyles.org uses an invalid security certificate. The certificate is only valid for the following names: ssl905239.cloudflaressl.com, *.readthedocs.io, readthedocs.io Error code: SSL_ERROR_BAD_CERT_DOMAIN

@nijel
Copy link
Contributor

nijel commented Aug 8, 2018

Also it might be worth mentioning in the docs is need to adjust CAA if domain has one, see https://support.cloudflare.com/hc/en-us/articles/115000310832-Certification-Authority-Authorization-CAA-FAQ

@davidfischer
Copy link
Contributor

Also it might be worth mentioning in the docs is need to adjust CAA if domain has one

Good idea.

@ivankravets
Copy link

Do we have any options to make 301 Moved Permanently from HTTP to HTTPS using built-in CNAME SSL provided by Cloudflare?

We can inject JS redirect but it's not good for search engines.

@davidfischer
Copy link
Contributor

@ivankravets, I am going to start with 302s but redirects are coming.

@ivankravets
Copy link

@davidfischer Thank you so much for the fast response. Do you have any ETA? Will we have some checkbox in UI/Admin part?

@davidfischer
Copy link
Contributor

I don't have an ETA right now. There will be a checkbox in the admin. That's actually merged already and will go live at the next deploy. See #4483.

@davidfischer
Copy link
Contributor

There will be a checkbox in the admin

There is a checkbox in the admin now.

@ivankravets
Copy link

@davidfischer do you have any ideas why it does not redirect from http://docs.platformio.org to https://docs.platformio.org? However, it redirects from "nested" pages.

P.S: I enabled HTTPS for docs.platformio.org

@davidfischer
Copy link
Contributor

There are no redirects in place for custom domains. Right now, all that checkbox does is make all the "view docs" links anywhere on Read the Docs an HTTPS link. The plan is to use that checkbox to do HTTPS redirects but that is not in place today.

@omidraha
Copy link

Hi,
I configure my domain as below:

Cloudflare:

screenshot_2018-09-18 dns omidraha com or omidraha com s account cloudflare - web performance security

rtd:

screenshot_2018-09-18 edit domains read the docs

But still this address http://omidraha.com is not automatically forced to https://omidraha.com
So what extra configuration I need to do to force http://omidraha.com to https://omidraha.com ?

@stsewd
Copy link
Member

stsewd commented Sep 18, 2018

@omidraha please see #2652 (comment)

@agjohnson
Copy link
Contributor

I'm going to close up this issue, as we do now support custom domains through Cloudflare now. If you are hitting any issues with custom domains, be sure to open up a new ticket!

@ryanpitts
Copy link

There are no redirects in place for custom domains. Right now, all that checkbox does is make all the "view docs" links anywhere on Read the Docs an HTTPS link. The plan is to use that checkbox to do HTTPS redirects but that is not in place today.

Is there an issue that's tracking work toward automatic HTTPS redirects? Sorry if I missed it, but did a search and didn't turn up something specific. Thanks again for enabling HTTPS support for custom-domain projects, I'm excited to be able to push all traffic that direction for our stuff!

@stsewd
Copy link
Member

stsewd commented Jan 8, 2019

@ryanpitts #4641 #4135

@ryanpitts
Copy link

@stsewd ohhhhhhh. Haha, thank you! Apparently "https" isn't a particularly useful search term across GitHub issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code
Projects
None yet
Development

No branches or pull requests