Reverse Proxy Container with Nginx for Python Flask Gunicorn App - To-Do
273
Reverse Proxy Container with Nginx for Python Flask Gunicorn App - To-Do
For this container I have based myself on the official image of Nginx Alpine in Docker hub.
This container will only connect to the frontend network through which it will have access to the flaskapp container and based on the nginx server's reverse proxy configuration it will forward all your requests to that container.
I launch the container in detach mode and tell it to be removed when it finishes running.
I also make use of environment variables to configure its runtime environment and port bind port 80 of the container to port 80 of the docker host.
The configuration of the nginx server is passed through a bind mount from my configuration file to the default configuration file of the nginx server, so when the service starts it will be executed with the desired configuration.
web server:
docker run -d --rm --name webserver \
-e APP_ENV="<environment>" \
-e APP_NAME="<host-name>" \
-e APP_DEBUG="<true-or-false>" \
-e SERVICE_NAME="<service-name>" \
-p 80:80 \
-v ./nginx/conf.d/app.conf:/etc/nginx/conf.d/default.conf:ro \
--network frontend \
nginx:1.23.3-alpine
We can access the container logs to verify its execution:
docker logs webserver
Content type
Image
Digest
sha256:12e973917…
Size
15.9 MB
Last updated
over 3 years ago
docker pull lacalvom/webserver