An open API service indexing awesome lists of open source software.

https://github.com/gh640/traefik-examples

Examples to use Traefik reverse proxy v2 with `docker-compose`.
https://github.com/gh640/traefik-examples

traefik traefik-v2

Last synced: 7 months ago
JSON representation

Examples to use Traefik reverse proxy v2 with `docker-compose`.

Awesome Lists containing this project

README

          

# Traefik examples

Examples to use [Traefik reverse proxy](https://traefik.io/) v2 with `docker-compose`.

## Examples

1. `whoami`: Single service with `traefik/whoami`
1. `nginx`: Multiple services with `nginx`
1. `https-with-traefik-default-cert`: https (TLS) using Traefik default self-signed certificate
1. `https-with-self-signed-cert`: https (TLS) using self-signed certificate
1. `https-with-letsencrypt`: https (TLS) using Let's Encrypt

## Usage

### `whoami`

```bash
cd repo-root/whoami/
docker-compose up -d
```

```bash
http 127.0.0.1 Host:whoami.docker.localhost
```

### `nginx`

```bash
cd repo-root/nginx/
docker-compose up -d
```

```bash
http 127.0.0.1 Host:tako.example.com
http 127.0.0.1 Host:ika.example.com
```

### `https-with-traefik-default-cert`

```bash
cd repo-root/https-with-traefik-default-cert/
echo 'DOMAIN=localhost' > .env
docker-compose up -d
```

```bash
http --verify=no --default-scheme=https localhost
```

### `https-with-self-signed-cert`

```bash
cd repo-root/https-with-self-signed-cert/
echo 'DOMAIN=localhost' > .env
docker-compose up -d
```

```bash
http --verify=no --default-scheme=https localhost
```

The certificate is stored in a Docker volume named `certs`. Please clear the volume once you've finished.

```bash
docker volume rm https-with-self-signed-cert_certs
```

### `https-with-letsencrypt`

You need to make the server public first so that the Let's Encrypt server can access your server.

```bash
cd repo-root/https-with-letsencrypt/
echo 'DOMAIN=mydomain.com' > .env
docker-compose up -d
```

```bash
http --verify=no --default-scheme=https [IP] Host:mydomain.com
```

If you want to get a valid certificate, comment out the line for `caServer`:

`traefik.yml`:

```yaml
# caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"
```

The certificate is stored in a Docker volume named `letsencrypt`. Please clear the volume once you've finished.

```bash
docker volume rm https-with-letsencrypt_letsencrypt
```

## Links

- [GitHub - traefik/traefik: The Cloud Native Application Proxy](https://github.com/traefik/traefik)
- [Traefik](https://doc.traefik.io/traefik/)