AnswerDotAI / fasthtml-example

Example fasthtml applications demonstrating a range of web programming techniques
Apache License 2.0
581 stars 82 forks source link

SSL Example #29

Closed plops closed 2 weeks ago

plops commented 2 weeks ago

An example of how to start the fasthtml fastapp with a let's encrypt certificate and https would be helpful.

plops commented 2 weeks ago

I think this has nothing to do with Python. Apparently, one would just run nginx as a proxy. I used this nginx.conf:

events {} http { server { listen 80; listen [::]:80; server_name rocketrecap.com;

return 301 https://$server_name$request_uri;

}

server { listen 443 ssl; listen [::]:443 ssl; server_name rocketrecap.com;

ssl_certificate  /etc/letsencrypt/live/rocketrecap.com/fullchain.pem;
ssl_certificate_key  /etc/letsencrypt/live/rocketrecap.com/privkey.pem;

location / {
    proxy_pass http://127.0.0.1:5001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

} }