Search code examples
python-3.xapachenginxwebserversanic

Python3 Sanic + ssl certificate


First of all, I am doing this for the first time and I know that I am lost.

I want to use Python Sanic as the Framework for my website. But I ALSO want to use my SSL certificate and my Domain. The method in the Sanic docs doesn't work. I search in the web and found that I need nginx or Apache2. But I have no idea what to do then.


Solution

  • It is probably best to use Nginx proxy for this. There should soon be a complete guide to this at https://sanic.readthedocs.io/en/latest/sanic/nginx.html (once docs are rebuilt, soon).

    To enable built-in SSL support,

    app.run(host="0.0.0.0", port=443, ssl=dict(
        cert="/etc/letsencrypt/live/example.com/fullchain.pem",
        key="/etc/letsencrypt/live/example.com/privkey.pem",
    ))