Skip to content

Unable to use AWS Cloudfront as proxy to serve RTD project at custom domain via https #3938

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
ryanpitts opened this issue Apr 11, 2018 · 10 comments
Labels
Support Support question

Comments

@ryanpitts
Copy link

I'm trying to use AWS Cloudfront as a proxy to securely serve this RTD project at a custom domain.

It feels like it should work, and in fact it almost works. Currently the custom domain forces all traffic to https, but then forwards to the secure readthedocs.io project domain instead of serving at the custom domain.

I'm following the documentation here for serving RTD projects at alternate domains. It suggests a handful of custom headers to set. A couple of key things to note:

I'm hoping that someone else might have some experience with making Cloudfront work here (or alternatively, can explain why there's no way to make it work if I can't forward Host). Really seems like it's thisclose.

@humitos
Copy link
Member

humitos commented Apr 11, 2018

The key thing of that nginx configuration is the proxy_pass: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

With the current configuration, we are getting just a 302 from https://securitytraining.opennews.org/ pointing to the URL in RTD.

@humitos humitos added the Support Support question label Apr 11, 2018
@ryanpitts
Copy link
Author

thanks @humitos! There's not a direct way to define proxy_pass in the AWS Cloudfront config—I think the analog is setting the origin domain. Here's the relevant part of the Cloudfront distribution config:

screen shot 2018-04-11 at 4 33 43 pm

It's a bit cut off in the screenshot, but the value of the "Origin Domain Name" field is set to the-field-guide-to-security-training-in-the-newsroom.readthedocs.io

@stsewd
Copy link
Member

stsewd commented Aug 31, 2018

RTD now supports https on custom domains, let us know if you still need help.

@stsewd stsewd closed this as completed Aug 31, 2018
@ryanpitts
Copy link
Author

oh fantastic! thank you!

@stsewd
Copy link
Member

stsewd commented Aug 31, 2018

Here are the docs btw https://docs.readthedocs.io/en/latest/alternate_domains.html#cname-ssl

@ryanpitts
Copy link
Author

ryanpitts commented Sep 6, 2018

First of all, thank you so much for building this feature into RTD! I'm not sure if I should reopen this ticket (or probably create a new one), but now that I've followed this documentation and switched our project to use https on a custom domain as described, I'm noticing that:

I've checkmarked "Always use HTTPS for this domain" in the RTD admin for this project, which sounds like it would enable automatic forwarding. Is it possible this is a bug, or is this expected behavior and I'm misunderstanding here?

@stsewd
Copy link
Member

stsewd commented Sep 6, 2018

@ryanpitts I think this is the same problem as #4395 (comment)

@davidfischer
Copy link
Contributor

As @stsewd suggested, we are working toward implementing redirects. They are a bit harder as most documentation is served without actually hitting our app/database layer but we need to hit that layer to tell whether we have successfully provisioned the certificate and that the "always use HTTPS" checkbox is selected. I'm actively working toward this so stay tuned.

@ryanpitts
Copy link
Author

Awesome! Thanks so much for the update. And for working on https for custom domains overall. Super helpful and appreciated.

@agjohnson
Copy link
Contributor

Opened #4641 to track changes to always redirect to HTTPS/enable HSTS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Support question
Projects
None yet
Development

No branches or pull requests

5 participants