Introduction to a Modern Reverse-Proxy: Traefik

Reading Time: 3 minutes

Traefik is an open source API gateway, written in Golang and was developed in a Unix-centric way. It is designed to simplify the complexity regarding microservices operations. Traefik performs auto-configuration of services, which means that the developer only needs to worry about developing and deploying applications.
Traefik auto-configures with sensible defaults and sends a request to the said service. With changing requirements and needs of various microservices, it takes care of its services by following a pluggable architecture. 

Traefik supports major technologies such as Docker, AWS, Kubernetes, Mesos and Marathon. These engines have their own integration points called providers.  It does not require a static configuration file. The providers are responsible for connecting to the orchestration engine and determining the services running on it. It then provides this information to the Traefik server, which can apply this to its routing. 

Traefik can integrate with multiple providers at the same time.

With nginx as a competitor in the market, Traefik is still able to make its way gradually to the top by providing better features with monitoring and observability and support for protocols.


Go to: Traefik-Release and download the suitable version available. 
Unpack the archieve: tar -zxvf <file-name>.
The folder contains a traefik executable with two other files.

tar -zxvf traefik_v2.4.2_linux_amd64.tar.gz

Traefik CLI

First, let’s validate the version of Traefik.

./traefik version

This output displays the Traefik version with information related to the platform and the date on which the Traefik binary was created.

In general, the traefik command has the following syntax:

traefik [command] [flags] [arguments]

In this command, all the arguments are optional.
Let’s start traefik.

sudo ./traefik
INFO[0000] Configuration loaded from the flags.

The command start listening at port 80. Lets hit a curl request to localhost to verify.
curl -i http://localhost/

The cURL request gets a 404 page not found response from the server. This is the default response we should get out of Traefik.

Traefik API

Most importantly, Traefik provides REST API which accesses all the information available in it. These APIs are reachable on port 8080

Traefik Dashboard

Traefik dashboard displays the status of all components configured in it. To enable the Traefik dashboard, you need to use start traefik like:
sudo ./traefik -api.insecure true

Dashboard will now be accessible on http://localhost:8080

  The dashboard shows TCP and UDP services. These are two listening ports with HTTP based applications.

Adoption of microservices have changed the requirements from API gateway. Established market products such as Nginx and HAProxy have tried to adapt these features but still lack in providing the first-class support of all needs.


Written by 

Vidushi Bansal is a Software Consultant [Devops] at Knoldus Inc. She is passionate about learning and exploring new technologies.