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

Update to traefik 3; Updated readme #8

Merged
merged 2 commits into from
Sep 13, 2024
Merged
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
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,27 @@ jobs:
run: cd examples && docker compose -f docker-compose.local.yml up -d
- name: 'Test hello-world'
run: curl http://hello-world.test
prod-setup:
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: actions/checkout@v4
- name: 'Setup Docker'
uses: docker-practice/actions-setup-docker@master
- name: 'Debug versions'
run: |
docker --version
- name: 'Add hosts to /etc/hosts'
run: |
sudo echo "127.0.0.1 reverse-proxy.test" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 hello-world.test" | sudo tee -a /etc/hosts
- name: 'Copy configuration files'
run: cp -r configs-local configs
- name: 'Start reverse proxy with local setup'
run: docker compose -f docker-compose.prod.yml up -d --wait
- name: 'Test dashboard'
run: curl http://reverse-proxy.test/dashboard/#/
- name: 'Start hello-world example'
run: cd examples && docker compose -f docker-compose.prod.yml up -d
- name: 'Test hello-world'
run: curl http://hello-world.test
9 changes: 5 additions & 4 deletions configs-local/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ entryPoints:
address: ":8082"

# Access logs
# accessLog: fields:
# headers:
# names:
# User-Agent: keep
#accessLog:
# fields:
# headers:
# names:
# User-Agent: keep

providers:
docker:
Expand Down
9 changes: 5 additions & 4 deletions configs-prod/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ entryPoints:
address: ":8082"

# Access logs
# accessLog: fields:
# headers:
# names:
# User-Agent: keep
#accessLog:
# fields:
# headers:
# names:
# User-Agent: keep

providers:
docker:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ networks:
- subnet: 10.100.100.0/24
services:
traefik:
image: traefik:2.11.3
image: traefik:v3.1.2
restart: always
container_name: reverse_proxy_traefik
ports:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ networks:
driver: bridge
services:
traefik:
image: traefik:2.11.3
image: traefik:v3.1.2
restart: always
container_name: reverse_proxy_traefik
ports:
Expand Down
19 changes: 19 additions & 0 deletions examples/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.8'
services:
hello-world:
image: nginx
labels:
- "traefik.enable=true"
- "traefik.docker.network=reverse-proxy-docker-traefik_routing"
- "traefik.http.routers.test.rule=Host(`hello-world.test`)"
- "traefik.http.routers.test.entrypoints=web"
- "traefik.http.services.test.loadbalancer.server.port=80"
- "traefik.http.routers.test-https.rule=Host(`hello-world.test`)"
- "traefik.http.routers.test-https.entrypoints=websecure"
- "traefik.http.routers.test-https.tls=true"
networks:
- reverse-proxy
networks:
reverse-proxy:
name: reverse-proxy-docker-traefik_routing
external: true
67 changes: 37 additions & 30 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
# Traefik 2 config
# Traefik Setup with Docker Compose


This is a resuseable traefik config for usage on a virtual server or for local debelopment using docker-compose.
This is a reusable Traefik config for usage on a virtual server or for local development using Docker Compose.
It uses:
- Traefik 2
- docker-compose
- Let's encrypt
- [Traefik 3](https://traefik.io/traefik/)
- [Docker](https://www.docker.com/)
- [Let's encrypt](https://letsencrypt.org/) (Optional)

> [!NOTE]
> Check out **solidtime - The modern Open Source Time-Tracker** at [solidtime.io](https://www.solidtime.io)

## Table of content

- [Traefik 2 config](#traefik-2-config)
- [Table of content](#table-of-content)
- [Production setup](#production-setup)
- [Setting up traefik](#setting-up-traefik)
- [Traefik dashboard](#traefik-dashboard)
- [Connect docker compose service to reverse-proxy](#connect-docker-compose-service-to-reverse-proxy)
- [SSL configuration](#ssl-configuration)
- [Global middlewares](#global-middlewares)
- [Access Logs](#access-logs)
- [Setup for local development](#setup-for-local-development)
- [Setting up traefik](#setting-up-traefik-1)
- [Traefik dashboard](#traefik-dashboard-1)
- [Connect docker compose service to reverse-proxy](#connect-docker-compose-service-to-reverse-proxy-1)
- [Enable SSL locally](#enable-ssl-locally)
- [Enable SSL in the docker compose file](#enable-ssl-in-the-docker-compose-file)
- [FAQ](#faq)
- [Credits](#credits)
- [License](#license)
* [Production setup](#production-setup)
+ [Setting up traefik](#setting-up-traefik)
+ [Traefik dashboard](#traefik-dashboard)
+ [Connect docker compose service to reverse-proxy](#connect-docker-compose-service-to-reverse-proxy)
+ [SSL configuration](#ssl-configuration)
+ [Global middlewares](#global-middlewares)
+ [Access Logs](#access-logs)
* [Setup for local development](#setup-for-local-development)
+ [Setting up traefik](#setting-up-traefik-1)
+ [Traefik dashboard](#traefik-dashboard-1)
+ [Connect docker compose service to reverse-proxy](#connect-docker-compose-service-to-reverse-proxy-1)
+ [Enable SSL locally](#enable-ssl-locally)
+ [Enable SSL in the docker compose file](#enable-ssl-in-the-docker-compose-file)
* [FAQ](#faq)
* [Credits](#credits)
* [License](#license)

## Production setup

Expand Down Expand Up @@ -82,14 +79,14 @@ It uses:
```bash
docker compose up -d
```
7. Check that traefik is running smoothly
7. Check that Traefik is running smoothly
```bash
docker compose logs
```

### Traefik dashboard

The traefik dashboard is now available under:
The Traefik dashboard is now available under:
```
https://reverse-proxy.somedomain.com
```
Expand Down Expand Up @@ -198,7 +195,7 @@ Examples:

### Access Logs

To enable the traefik access logs in the production configuration, open the file `traefik.yml` within the config folder and uncomment the `accessLog` section.
To enable the Traefik access logs in the production configuration, open the file `traefik.yml` within the config folder and uncomment the `accessLog` section.

```yml
# Access logs
Expand All @@ -207,7 +204,7 @@ accessLog: {}

## Setup for local development

### Setting up traefik
### Setting up Traefik

1. Clone repository
```bash
Expand Down Expand Up @@ -245,7 +242,7 @@ accessLog: {}

### Traefik dashboard

The traefik dashboard is now available under:
The Traefik dashboard is now available under:
```
http://reverse-proxy.test
```
Expand Down Expand Up @@ -286,7 +283,7 @@ services:

**Specifying port if service exposes multiple ports**

If your service exposes multiple ports traefik does not know which one it should use.
If your service exposes multiple ports Traefik does not know which one it should use.
With this config line you can select one:

```yaml
Expand Down Expand Up @@ -349,6 +346,16 @@ services:
- ...
```

## FAQ

**I have a IPv6-only server, what do I need to change?**

GitHub currently does not support cloning a repository over IPv6. You can clone from my Codeberg mirror instead:

```bash
git clone https://codeberg.org/korridor/reverse-proxy-docker-traefik.git
```

## Credits

I used the following resources to create this setup:
Expand Down