Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dbushell/docker-traefik
🐁 Use Traefik to proxy Docker containers for *.localhost development.
https://github.com/dbushell/docker-traefik
Last synced: 3 months ago
JSON representation
🐁 Use Traefik to proxy Docker containers for *.localhost development.
- Host: GitHub
- URL: https://github.com/dbushell/docker-traefik
- Owner: dbushell
- License: mit
- Created: 2021-02-19T17:35:31.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-10T12:50:31.000Z (7 months ago)
- Last Synced: 2024-11-04T22:37:31.934Z (4 months ago)
- Language: Shell
- Homepage:
- Size: 14.6 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🐋 Docker 🐁 Traefik 🦄 .Localhost
Use Traefik to proxy Docker containers for `*.localhost` development. Assuming `*.localhost` domains resolve to the loopback interface.
Now updated to provided HTTPS for a custom domain.
## Usage
Create a bridge network named `traefik`:
```sh
docker network create -d bridge traefik
```Create an `.env` file (chmod 600):
```sh
TRFK_HOST_IP=127.0.0.1
TRFK_HTTP_PORT=80
TRFK_HTTPS_PORT=443
TRFK_ACME_DOMAIN=example.dev
[email protected]
TRFK_ACME_PROVIDER=cloudflare
TRFK_ACME_RESOLVER="1.1.1.1:53"
CF_DNS_API_TOKEN="see: https://go-acme.github.io/lego/dns/cloudflare/"
```Start the Traefik container (this repo):
```sh
docker-compose up -d
```### Discovery
Traefik will automatically discover containers in the `traefik` network that use labels. See [docker-compose.yml](/docker-compose.yml) for the full example service.
Insecure `.localhost` domain:
```yml
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
```Secure domain:
```yml
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.entrypoints=websecure"
- "traefik.http.routers.whoami.rule=Host(`whoami.${TRFK_ACME_DOMAIN}`)"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
```Or via the `dynamic.yml` config file:
```yml
http:
routers:
whoami:
entryPoints: ['websecure']
rule: "Host(`whoami.{{ env "TRFK_ACME_DOMAIN" }}`)"
service: whoami
services:
whoami:
loadBalancer:
servers:
- url: "http://whoami"
```See the [Traefik documentation](https://doc.traefik.io/traefik/providers/docker/) for more details.
* * *
[MIT License](/LICENSE) | Copyright © 2023 [David Bushell](https://dbushell.com)