reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Support https and how to config?

Open evandeng2009 opened this issue 2 years ago β€’ 2 comments

Describe the bug By default, Pynecone runs in http mode. No related info found in Docs, how to set it up?

To Reproduce Steps to reproduce the behavior:

  • Code/Link to Repo:

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version:
  • Reflex Version:
  • OS:
  • Browser (Optional):

Additional context Add any other context about the problem here.

evandeng2009 avatar Jul 10 '23 05:07 evandeng2009

https is supported by default. setting your api_url in rxconfig.py to an https url should work out of the box with no special configuration

ElijahAhianyo avatar Jul 10 '23 16:07 ElijahAhianyo

I have no Nginx or something similar to setup cert or key, just only Reflex/Pynecone. Where should I put the cert and key files? I want both of frontend and backend are https enabled.

evandeng2009 avatar Jul 11 '23 05:07 evandeng2009

@evandeng2009 while i believe uvicorn and probably next itself support TLS certs, etc natively, reflex doesn't currently expose it.

If you're looking for something simple to terminate TLS, then I'd recommend taking a look at caddy with automatic HTTPS.

You can get started with a Caddyfile in your app directory like so:

localhost
reverse_proxy localhost:3000
reverse_proxy /event/ localhost:8000

(change localhost on the first line to whatever domain you own, and it will provision TLS via letsencrypt automatically for you)

Execute caddy run, then fire up https://localhost to see your reflex site.

masenf avatar Jul 19 '23 22:07 masenf

Thank you @masenf , Caddy is a good tool for auto https. With reverse_proxy /event/ localhost:8000 and api_url=https://domain_only_without_specified_backend_port, users will see 80/http and 443/https only and this is what I want.

Caddy is more easy to use than other proxies like Ghostunnel as Caddy itself help get and renew the cert and key.

evandeng2009 avatar Jul 29 '23 19:07 evandeng2009