Traefik setup inspired by korridor/reverse-proxy-docker-traefik.
This Traefik setup is an easy way to setup a local or production reverse proxy to handle incoming requests from outside your docker environment.
First you will need to clone this repository.
git clone git@github.com:tjventurini/traefik-reverse-proxy.gitNavigate into the project directory in order to continue.
cd traefik-reverse-proxyNow simply run make init or make from within the project root directory. The wizard will guide you through 🧙♂️
make init# Run setup wizard
make init
# Start Traefik
make start
# Stop Traefik
make down
make stop # alias for 'make down'
# Uninstall Traefik
make clearYou can configure your traefik environment by editing the .env file. See the contents of that file for more information.
At the time of writing this the following options are available.
NETWORK_NAME=reverse-proxy
RESTART=no
DASHBOARD=true
HOST=localhost
Update your projects docker-compose.yml file so that it includes the network and labels as shown below. Also make sure that you do not expose any ports on your services.
version: '3.8'
# setup the network
networks:
frontend:
external:
name: reverse-proxy
services:
someservice:
# add the labels to the service configuration
labels:
- "traefik.enable=true"
- "traefik.docker.network=reverse-proxy"
# http
- "traefik.http.routers.someservice.rule=Host(`someservice.com`)"
- "traefik.http.routers.someservice.entrypoints=web"
# add the network to the service configuration
networks:
- frontend
# ...version: '3.8'
# setup the network
networks:
frontend:
external:
name: reverse-proxy
services:
someservice:
# add the labels to the service configuration
labels:
- "traefik.enable=true"
- "traefik.docker.network=reverse-proxy"
# https
- "traefik.http.routers.someservice.rule=Host(`someservice.com`)"
- "traefik.http.routers.someservice.entrypoints=websecure"
- "traefik.http.routers.someservice.tls=true"
- "traefik.http.routers.someservice.tls.certresolver=letsencrypt"
# add the network to the service configuration
networks:
- frontend
# ...