1

I wish to significant reduce number of public exposed ports, which currently used by many docker applications.

Each docker application consists of at least a Nginx and a Python Flask, which is a pretty common setup technique - https://blog.nolanemirot.com/2016/03/11/deploy-a-flask-app-with-gunicorn-and-docker/

I plan to follow this tutorial to setup https://www.digitalocean.com/community/tutorials/how-to-use-traefik-as-a-reverse-proxy-for-docker-containers-on-ubuntu-18-04

Unlike my docker applications which consists of Nginx and Python Flask, the given example is using WordPress as docker application example.

For my case, I was wondering, whether a Nginx still necessary, at each docker application side? Is it redundant, or should it still be there?

1 Answers1

2

[edit] Traefik will communicate with your docker daemon. It will listen for containers with "traefik" flags, and adjust its configuration. for example:

-l traefik.frontend.rule=Host:monitor.your_domain
-l traefik.port=8080

If your container is running an application that is listening on a network port on the docker network interface, then you just need to set -l traefik.port={you_apps_port}, and it should work. you need the container to be on the same docker network as traefik, which is "--network {name}" option is for.
So as long as your flask app can listen on a port, you won't need nginx. You also won't need to do port binding between your flask app container and your host.
You only need to access the traefik container on port 80 from outside docker networks.
If you want to have multiple apps running you might need to set up your hosts file or a (local?) DNS to point to your traefik host with multiple names, e.g:

127.0.0.1  app1.mytraefik
127.0.0.1  app2.mytraefik
127.0.0.1  app3.mytraefik

then set app1's label "frontend.rule=Host:app1.mytraefik". Traefik will read your http HOST header and direct requests over the docker network to your container on the port in the "traefik.port" label

Ivan
  • 56
  • 1
  • 7