From 22d05e8b960465fdeebc9c4a031c9ff4b01775e0 Mon Sep 17 00:00:00 2001 From: smilelikeshit Date: Thu, 22 Jul 2021 23:22:53 +0700 Subject: [PATCH] update version traefik to 2.4 --- README.md | 16 ++++++++++++- bin/start.sh | 0 bin/stop.sh | 0 docker-compose.yml | 21 ++++++++++++++--- traefik.config.toml | 2 +- traefik.toml | 56 ++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 87 insertions(+), 8 deletions(-) mode change 100644 => 100755 bin/start.sh mode change 100644 => 100755 bin/stop.sh diff --git a/README.md b/README.md index df3b5c6..218aa89 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,18 @@ # for more documentation # -https://docs.traefik.io/v2.1/ \ No newline at end of file +https://docs.traefik.io/v2.4/ + +# providers + - default using redis + + +# how to use +```bash +make start +make stop +``` + + +# support tls + - put your certificates on the folder cert/ \ No newline at end of file diff --git a/bin/start.sh b/bin/start.sh old mode 100644 new mode 100755 diff --git a/bin/stop.sh b/bin/stop.sh old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml index a378993..55a5bff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,10 @@ version: '3.7' services: - reverse-proxy: - image: traefik:v2.1 + traefik: + image: traefik:v2.4 # Enables the web UI and tells Traefik to listen to docker restart: unless-stopped + container_name: traefik-app ports: # The HTTP port - "80:80" @@ -16,7 +17,8 @@ services: - ./cert:/data - ./log:/log - ./traefik.toml:/etc/traefik/traefik.toml # Traefik static config - - ./traefik.config.toml:/etc/traefik/traefik.config.toml # Traefik dynamic config + # enable if u want using providers file + #- ./traefik.config.toml:/etc/traefik/traefik.config.toml # Traefik dynamic config networks: - traefik-gateway deploy: @@ -25,9 +27,22 @@ services: cpus: '0.25' memory: '256M' + redis: + image: redis:6.2.4-alpine + restart: unless-stopped + container_name: traefik-redis + networks: + - traefik-gateway + deploy: + resources: + limits: + cpus: '0.15' + memory: '128M' networks: + #make sure u've created the network below + #docker network create traefik-gateway -d bridge traefik-gateway: external: name: gateway diff --git a/traefik.config.toml b/traefik.config.toml index e455c2b..e4328cd 100644 --- a/traefik.config.toml +++ b/traefik.config.toml @@ -42,4 +42,4 @@ [tls] [[tls.certificates]] certFile = "/data/fullchain.pem" - keyFile = "/data/privkey.pem" + keyFile = "/data/privkey.pem" \ No newline at end of file diff --git a/traefik.toml b/traefik.toml index 7a7ac2b..baabb73 100644 --- a/traefik.toml +++ b/traefik.toml @@ -19,11 +19,61 @@ # This is how you tell traefik that it has to get the dynamic config from a config file # Note that the path is the path to the file inside Docker, not insider your machine! # If you want do use Docker itself for this check traefik docs! - [providers.file] - filename = "/etc/traefik/traefik.config.toml" - watch = true + + # uncomment below if you want providers file + #[providers.file] + # filename = "/etc/traefik/traefik.config.toml" + # watch = true + [providers.redis] + endpoints = ["127.0.0.1:6379"] [api] # With this you enable the web UI insecure = false dashboard = true + +[http] + [http.routers] + ######################################################################### + # http # + [http.routers.http-to-app] + # You can change the rules here and make it more complex. Check traefik + # docs! + rule = "Host(`app.example.com`)" + service = "app" + entrypoints = ["http"] + # enable if u want redirect to https + #middlewares = ["redirect"] + + ## https # + [http.routers.https-to-app] + rule = "Host(`app.example.com`)" + service = "app" + entrypoints = ["https"] + middlewares = ["app-compress"] + [http.routers.https-to-app.tls] + + [http.services] + # service + [http.services.app] + [http.services.app.loadBalancer] + passHostHeader = true + [[http.services.app.loadBalancer.servers]] + # This is where your dev app lives. + url = "http://url/" + + + ######################################################################## + + [http.middlewares] + [http.middlewares.redirect.redirectScheme] + scheme = "https" + average = 100 + burst = 50 + [http.middlewares.app-compress.compress] + + +[tls] + [[tls.certificates]] + certFile = "/data/fullchain.pem" + keyFile = "/data/privkey.pem"