---
title: "Traefik"
slug: "traefik"
updated: 2023-07-05T08:41:47Z
published: 2023-07-05T08:41:47Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://traceabledocs.document360.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Traefik

Traefik is an open-source reverse proxy and load balancer designed for microservices and containerized applications. It is commonly used in cloud-native environments and works well with container orchestration platforms like Docker, Kubernetes, and Swarm.

Traefik acts as a gateway for incoming traffic, routing requests to the appropriate services based on rules and configurations. It dynamically discovers new services as they are added or removed, making it flexible and scalable in dynamic environments. It also provides features such as SSL/TLS termination, traffic routing based on HTTP headers or paths. Traceable provides a plugin to capture the data passing through Traefik and sends it to Traceable's Platform agent, that in turn sends the data to Traceable's Platform for further analysis. The following is a high-level deployment diagram of Traceable's Traefik plugin:

![traceable_traefik_deployment_diagram](https://cdn.document360.io/24f14f07-13d1-4684-8fae-6d8f811768ee/Images/Documentation/traceable_traefik_deployment_diagram.png)

NoteTraceable's Traefik plugin does not support blocking.

---

## Before you begin

Make a note of the following points before you proceed with deployment:

- Make sure that Traceable Platform agent is already installed and configured. For more information on installing the agent, see [Platform agent](/docs/tpa).
- Make a note of Platform agent's host name or IP address. This would be required when you configure the plugin.

---

## Deployment

Deploying Traceable's Traefik plugin requires configuring the Traefik static configuration and Traefik dynamic configuration. The download location and plugin version are configured as static condition. The dynamic configuration is to configure middleware and router. Middleware and router are two important concepts in Traefik.

- **Middleware** - Middleware in Traefik refers to a set of actions or modifications that can be applied to requests or responses passing through Traefik. Middleware allows you to customize and enhance the behavior of your services without modifying the services themselves.
- **Router** - Routers define how incoming requests are matched and routed to the appropriate services. They act as traffic managers within Traefik. A router consists of a set of conditions and rules that determine which requests should be directed to which services.

The static and dynamic configurations are added to `traefik.yml` file.

### Configure download location

Traceable's Traefik plugin is available at Traceable's Github repository. This location is configured in `traefik.yml` file as shown below.

```yaml
experimental:
  plugins:
    plugin-traceableai:
      moduleName: github.com/traceableai/traceable_traefik_plugin
      moduleVersion: 1.0.0
```

### Configure middleware

Configure middleware as shown below. Add the service name to `servicename`. This is the name that would be visible in Traceable's UI. Configure the Platform agent's IP address or hostname in `tpaendpoint` as shown below:

```yaml
  middlewares:
    my-plugin-traceableai:
      plugin:
        traceableai:
          allowedContentTypes:
            - "json"
            - "xml"
            - "x-www-form-urlencoded"
            - "grpc"
          bodyCaptureSize: 131072
          serviceName: traefik
          tpaEndpoint: http://<REPLACE_WITH_TPA_HOST_OR_IP>:5442
```

### Configure router

Configure the router as shown below:

```yaml
http:
  routers:
    example-router:
      service: a-service
      rule: Headers(`host`, `frontend.local`)
      middlewares:
        - my-plugin-traceableai
```

---

## Upgrade

Upgrading Traceable's plugin requires updating the version number in the static configuration in `traefik.yml` file:

```yaml
experimental:
  plugins:
    traceableai:
      moduleName: "github.com/traceableai/traceableai_traefik_plugin"
      version: "v1.0.0"
```

---

## Uninstall

Uninstalling Traceable's plugin requires removing the Traceable configuration from the `traefik.yml&nbsp;`file.

The static configuration of Traefik refers to the initial configuration settings that are defined in a configuration file or as command-line options when starting Traefik. This configuration provides the basic setup and behavior for Traefik before it starts dynamically discovering services and making runtime adjustments.

Traefik's dynamic configuration refers to the ability of Traefik to adapt and update its configuration in real-time based on changes in the environment. This allows Traefik to dynamically discover services, adjust routing rules, and incorporate new configurations without requiring a restart.
