Feat/traefik as gateway (#13)

* feat: set up traefik

* feat: set up deluge+traefik

* feat: enable https
This commit is contained in:
Marc 2022-12-04 11:14:41 -05:00 committed by GitHub
parent 2b246f7e38
commit fdd4757237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 1 deletions

View file

@ -14,7 +14,15 @@ services:
- 6881:6881 - 6881:6881
- 6881:6881/udp - 6881:6881/udp
restart: unless-stopped restart: unless-stopped
labels:
- traefik.http.routers.deluge.rule=PathPrefix(`/deluge/`)
- traefik.http.routers.deluge.tls=true
- traefik.http.routers.deluge.tls.certresolver=lets-encrypt
- traefik.http.middlewares.deluge-stripprefix.stripprefix.prefixes=/deluge
- traefik.http.routers.deluge.middlewares=deluge-stripprefix,deluge-base-headers
- traefik.http.middlewares.deluge-base-headers.headers.customrequestheaders.X-Deluge-Base=/deluge/
- traefik.http.services.deluge.loadbalancer.server.port=8112
- traefik.enable=true
networks: networks:
default: default:
name: kong-net name: kong-net

1
traefik/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
acme.json

View file

@ -0,0 +1,19 @@
version: '3.7'
services:
traefik:
image: traefik:v2.9
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.toml:/traefik.toml
- ./traefik_dynamic.toml:/traefik_dynamic.toml
- ./acme.json:/acme.json
networks:
default:
name: kong-net
external: true

29
traefik/tasks.py Normal file
View file

@ -0,0 +1,29 @@
import invoke
import pathlib
PATH = pathlib.Path(__file__).parent
@invoke.task()
def start(ctx):
with ctx.cd(PATH):
ctx.run("docker-compose up -d")
@invoke.task()
def stop(ctx):
with ctx.cd(PATH):
ctx.run("docker-compose down")
@invoke.task()
def restart(ctx):
with ctx.cd(PATH):
ctx.run("docker-compose restart")
ns = invoke.Collection("traefik")
ns.add_task(start)
ns.add_task(restart)
ns.add_task(stop)

28
traefik/traefik.toml Normal file
View file

@ -0,0 +1,28 @@
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
[entryPoints.websecure]
address = ":443"
[log]
level = "DEBUG"
[api]
dashboard = true
[certificatesResolvers.lets-encrypt.acme]
email = "traefik@karnov.club"
storage = "acme.json"
[certificatesResolvers.lets-encrypt.acme.tlsChallenge]
[providers.docker]
watch = true
useBindPortIP = true
network = "kong-net"
exposedByDefault = false
[providers.file]
filename = "traefik_dynamic.toml"

View file

@ -0,0 +1,6 @@
[http.routers.api]
rule = "Host(`spadinaistan.karnov.club`)"
entrypoints = ["web"]
service = "api@internal"
[http.routers.api.tls]
certResolver = "lets-encrypt"