Simple Reverse Proxy With Traefik

Introduction

I usually like used Nginx as proxy to host multiple services on the same server, but however, when we need to use a quick and simple configuration, it is good to use Traefik as our proxy server.

What exactly is Traefik ???

An open-source reverse proxy and load balancer for HTTP and TCP-based applications that is easy, dynamic, automatic, fast, full-featured, production proven, provides metrics, and integrates with every major cluster technology.

Environment

Domains:

For this test add the following items to the host file to try it out locally.

root@vagrant:/home/vagrant# echo '127.0.0.1     blog.test.localdomain' > /etc/hosts
root@vagrant:/home/vagrant# echo '127.0.0.1 wiki.test.localdomain' >> /etc/hosts
root@vagrant:/home/vagrant# cat /etc/hosts
127.0.0.1 blog.test.localdomain
127.0.0.1 wiki.test.localdomain
version: '3.2'

services:
blog:
image: ghost
ports:
- 8082:2368
volumes:
- 'blog_data:/var/lib/ghost/content'
wiki:
image: 'docker.io/bitnami/dokuwiki:20200729-debian-10'
ports:
- '8083:8080'
volumes:
- 'wiki_data:/bitnami/dokuwiki'
volumes:
wiki_data:
driver: local
blog_data:
driver: local
version: '3.2'

services:
proxy:
image: traefik:2.0
ports:
- 8081:8080
- 80:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.yml:/etc/traefik/traefik.yml
version: '3.2'

services:
blog:
image: ghost
ports:
- 8082:2368
volumes:
- 'blog_data:/var/lib/ghost/content'
labels:
- "traefik.http.routers.blog.rule=Host(`blog.test.localdomain`)"


wiki:
image: 'docker.io/bitnami/dokuwiki:20200729-debian-10'
ports:
- '8083:8080'
volumes:
- 'wiki_data:/bitnami/dokuwiki'
labels:
- "traefik.http.routers.wiki.rule=Host(`wiki.test.localdomain`)"

Conclusion

If we don’t need to set complicated rules and just need a simple reverse proxy, Traefik it’s a good choice

DevOps Consultant. I’m strongly focused on automation, security, and reliability.