tiangolo / uwsgi-nginx-docker

Docker image with uWSGI and Nginx for applications in Python (as Flask) in a single container.
https://hub.docker.com/r/tiangolo/uwsgi-nginx/
Apache License 2.0
648 stars 285 forks source link

building uwsgi with SSL support #35

Closed Zahlii closed 5 years ago

Zahlii commented 6 years ago

Hi, would it be possible to enable SSL support for uwsgi? Without SSL support, trying to establish websocket connections will lead to the worker crashing down.

I guess the modification should be something like

# Install uWSGI
RUN pip install uwsgi`

to

# uwsgi-ssl version (not tested)
RUN apt-get install libssl-dev
RUN UWSGI_PROFILE_OVERRIDE=ssl=true pip install uwsgi -I --no-cache-dir`

Also related: https://stackoverflow.com/questions/24183053/how-to-build-uwsgi-with-ssl-support-to-use-the-websocket-handshake-api-function

tiangolo commented 6 years ago

TLS / SSL handling is a whole problem by itself, even though it sounds like something simple.

I suggest using a separate container to handle it, that is known as a TLS termination proxy, let me suggest Traefik. With it you can also automatize the generation of free HTTPS certificates with Let's encrypt, with auto-renewal included.

That's what I do in this other project: https://github.com/tiangolo/full-stack

tiangolo commented 5 years ago

I assume you were able to solve your problem, so I'll close this issue now.

But feel free to re-open it, add more comments or create new issues.


As a side note, you can set up a Docker Swarm mode cluster to handle HTTPS automatically for you in 20 minutes with DockerSwarm.rocks.

Now, if you are building an API, I recently created https://github.com/tiangolo/fastapi to facilitate all the needed parts, it would have about 800% the performance of Flask with this image, you would need to write half of the code (or less), etc.

It also has support for WebSockets automatically, as it an asynchronous framework (based on Starlette), which is what the StackOverflow link refers to.