tiangolo / uwsgi-nginx-flask-docker

Docker image with uWSGI and Nginx for Flask applications in Python running in a single container.
https://hub.docker.com/r/tiangolo/uwsgi-nginx-flask/
Apache License 2.0
2.98k stars 608 forks source link

flask ssl certificates #116

Closed dlcrista closed 4 years ago

dlcrista commented 5 years ago

Assuming that I'm using the file structure from example-flask-python3.7-index, how should I edit the nginx.conf file to accept an ssl certificate and a private key and serve flask over https?

tiangolo commented 5 years ago

Sorry for the delay! I was busy building FastAPI.

The suggested way to have HTTPS is using Traefik, it can acquire free Let's Encrypt certificates (including renewals).

You can set up a Docker Swarm mode cluster with Traefik for HTTPS in about 20 min.

And then you can use one of the project generators that have everything set up to be integrated into the cluster. I just added information on that to the docs: https://github.com/tiangolo/uwsgi-nginx-flask-docker#project-generators

dlcrista commented 5 years ago

Thanks!

Btw, have this ever happened to you?

WARN received SIGTERM indicating exit request

and then uwsgi and nginx stops. I'm not sure what is sending the sigterm

tiangolo commented 5 years ago

Hmm, where do you see that? In the logs?

Are you sure Nginx stops too? Or is it only uwsgi?

tiangolo commented 5 years ago

I just finished a big refactor to allow creating a file /app/nginx.conf. In it, you could add any custom configurations you need, including a custom TLS certificate.

The docs are here: https://github.com/tiangolo/uwsgi-nginx-flask-docker#overriding-nginx-configuration-completely


I still suggest you use Traefik for HTTPS, but in case you definitely need to customize it, there's the option now.

BTW, I created DockerSwarm.rocks to document how to set everything up.

github-actions[bot] commented 4 years ago

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.