Can I please ask advice on setting up my first reverse proxy on my dev machine for testing?

Hi all,

I'm new to the concepts here but getting my head around it but am stuck so thought I'd ask here.

My setup

  • a flask app running on port 8000
  • traefik running
  • a network running

This is done via docker-compose. I'm on ubuntu 18.04.

Before Traefik:

The flask app runs well by itself if I have no proxy setup at all. I can head to localhost:8000 and it works a treat. That's great.

What I expect:

I want to test a reverse proxy. So I want to head to localhost:5000 and have Traefik grab the data from 8000 and send it to the browser. I assume that's how this is meant to work? I ask this as I'm really fighting what I thought would be quite simple. In my mind, all traffic going through Traefik would show to the end user as being on port 5000 (so that all backend activity/addresses are hidden).

What's happening:
I am heading to localhost:5000 and I get a 404 error. Not only that, the image that's meant to go with the 404 error is showing its url as http://localhost:8000/static/images/404.png Isn't the port 8000 never meant to show to the end user?

My setup:

docker-compose.yml


    version: '3'

    services:
      flask:
        # build the Dockerfile
        build: .
        image: logrr:1.0.0
        container_name: flask
        restart: always
        command: >
          gunicorn -b 0.0.0.0:8000
            --access-logfile -
            --reload
            "logrr.app:create_app()"
        volumes:
          - '.:/logrr'
        networks:
        - proxy
        ports:
          - "8000"
        labels:
          # This will mark this docker service as a backend with name flaskā€
          # It will create a rule in Traefik that all traffic coming from localhost
          # should be redirected to this docker service to port 8000.
          - "traefik.enable=true"
          - "traefik.backend=flask"
          - "traefik.frontend.rule=Host:localhost"
          - "traefik.port=8000"
          - "traefik.docker.network=proxy"



      traefik:
        image: traefik # The official Traefik docker image

        command: --api --docker --loglevel=debug # Enables the web UI and tells Traefik to listen to docker


        ports:
          - "443:443"   # The encrypted port
          - "80:80"     # The HTTP port
          - "8080:8080" # The Web UI (enabled by --api)
          - "8000:8000" # the flask port. Will this work?
          - "5000:5000" # the traefik frontend port.  Will this work?

        volumes:
          - /var/run/docker.sock:/var/run/docker.sock  # Traefik auto-detects containers on the network by reading from the Docker socket
          - ./traefik/traefik.toml:/etc/traefik/traefik.toml  # this is the Traefik configuration file
          - ./ssl:/ssl  # this directory will store self-signed certificates for enabling TLS (https) connections to Traefik

        labels:
          # accept connections to entry point 'https' & 'http' (these are defined in traefik.toml)
          - traefik.frontend.entryPoints=http localhost::5000
          # if the connection matches this front end rule, route the connection to this container
          # in this case, the connection must have a host name of 'traefik.docker.localhost'
          - traefik.frontend.rule=Host:traefik.docker.localhost
          # route frontend rule matches to port 8080 on this container
          - traefik.port=8080
          # enable Traefik to route to this container, this isn't always needed (I'll explain more when going over treafik.toml)
          - traefik.enable=true


        # add this container to the 'proxy' network
        networks:
          proxy:

        container_name: 'traefik'  # set the container name, it defaults to the service name if not defined

        expose:
          - 8080  # Exposed ports are only accessible to other containers on the same Docker network like so -> http://CONTAINER:PORT


    networks:
      proxy:

Here is my traefik.toml

debug = false

logLevel = "ERROR"
defaultEntryPoints = ["https","http"]

[entryPoints]
  [entryPoints.http]
  address = ":5000"

[retry]

Can anyone see what I'm doing wrong? The Traefik dashboard shows front end and back end for the flask app. It's just not behaving like I am expecting. Right now I don't want encryption or anything, I just want it to work in testing on my local machine.

Any help would be massively appreciated. I've spent days, had a few "ahah!" moments but really am at a wall now.

I hope nobody minds the bump. I'm still completely stuck with the same issue 2 weeks on now. I'm feeling pretty low on this so hoping someone can spot an obvious mistake?

Thanks a tonne...