Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traefik Proxy #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
tmp/
vendor/

*.bak
*.log
*.orig
*.rej
*.tmp
*~

docker-compose.override.yml
37 changes: 37 additions & 0 deletions projects/traefik/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Docker Network Proxy

## Quick Start

bin/up
echo "127.0.0.1 api.aspiredev.org staging.aspiredev.org" | sudo tee -a /etc/hosts
echo "::1 api.aspiredev.org staging.aspiredev.org" | sudo tee -a /etc/hosts

_(Windows users, **including WSL2**: edit `C:\Windows\System32\drivers\etc\hosts` instead of /etc/hosts)_

## Enabling the proxy in docker-compose.yml

Add the following to the service you want proxied, substituting `myservice` and `myhostname.local` appropriately

`myservice` can be anything you want, but it must be unique across all your docker containers

labels:
- "traefik.enable=true"
- "traefik.http.routers.myservice.rule=Host(`myhostname.local`)"
- "traefik.http.routers.myservice-https.rule=Host(`myhostname.local`)"
- "traefik.http.routers.myservice-https.tls=true"
networks:
- traefik

Add the following to the top level keys

networks:
traefik:
external: true

Finally, add the following lines to your `/etc/hosts` file (`C:\Windows\System32\drivers\etc\hosts` on Windows)

```
127.0.0.1 myhostname.local
::1 myhostname.local
```

5 changes: 5 additions & 0 deletions projects/traefik/bin/down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

cd $(dirname $0)/..

exec docker compose down "$@"
7 changes: 7 additions & 0 deletions projects/traefik/bin/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

cd $(dirname $0)/..

docker network create traefik >/dev/null 2>&1 || true

exec docker compose up -d "$@"
30 changes: 30 additions & 0 deletions projects/traefik/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
traefik:
image: traefik:3.3.2
restart: unless-stopped
command:
- "--api.dashboard=true"
- "--api.insecure=true"
- "--log.format=json"
- "--log.level=INFO"
- "--accesslog=true"
- "--accesslog.format=json"
- "--providers.docker.network=traefik"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web-secure.address=:443"
- "--global.checkNewVersion=false"
- "--global.sendanonymoususage=false"
- "--api.disabledashboardad=true"
ports:
- "${TRAEFIK_HTTP_PORT:-80}:80"
- "${TRAEFIK_HTTPS_PORT:-443}:443"
- "${TRAEFIK_DASHBOARD_PORT:-8080}:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik

networks:
traefik:
external: true