Applies to: reference, configuration, ingress-configuration

Ingress configuration file format

Configuration file example:

enable: true
accessLog:
  format: "common"
pilot:
    token: "<7088bb58-604c-4458-b63b-320fffca6a7d>"  
http:
  routers:
    my-route:
      entrypoints: "web"
      rule: "PathPrefix(`/api`)"
      service: my-api-server
      middlewares: ["my-route-strip", "traefik-compress"]
  middlewares:
    my-route-strip:
      stripPrefix:
        prefixes: "/api"
        forceSlash: false
    traefik-compress:  
      compress: 
        minResponseBodyBytes: 120000
    cache-headers:
      headers:
        customResponseHeaders: 
          "Cache-Control": "public,max-age=2592000"
  services:
    my-api-server:
      loadBalancer:
        passHostHeader: false
        servers:
          - url: "http://<MOPS_Engine_Url>:9003"

Top-Level Keys

  • enable

    • Purpose: Enables or disables the entire configuration for this specific section or feature.
    • Value: true in this case, meaning the configuration is active.
  • accessLog

    • Purpose: Configures access logging for the ingress traffic.
    • format: Defines the format of the access logs.
      • "common": Refers to a predefined log format (e.g., similar to NGINX/Apache’s Common Log Format).
  • pilot

    • Purpose: Configures the connection to Traefik Pilot, a cloud-based management and monitoring service offered by Traefik Labs.
    • token: The unique identifier (API token) for authenticating the Traefik instance with the Traefik Pilot service.
    • Effect: When enabled, Traefik can send telemetry data to the Traefik Pilot dashboard for centralized monitoring, alerts, or insights.

http Configuration Section

  • routers

    • Purpose: Defines the routing rules for incoming HTTP requests.
    • Example: my-route
      • entrypoints: Specifies which Traefik entry points (e.g., web, websecure) this route listens on.
      • rule: Defines the matching condition for routing traffic.
        • Example: Routes requests with the prefix /api.
      • service: Specifies the backend service to route requests to (e.g., my-api-server).
      • middlewares: Lists middlewares applied to the route.
        • Example: "my-route-strip" and "traefik-compress".
  • middlewares

    • Purpose: Defines transformations or operations performed on the requests before reaching the backend.
    • Examples:
      • my-route-strip
        • stripPrefix: Removes a specified prefix from the request URL.
          • prefixes: Specifies the prefix to strip (e.g., /api).
          • forceSlash: When false, does not enforce a trailing slash after stripping.
      • traefik-compress
        • compress: Enables response compression.
          • minResponseBodyBytes: Compress responses only if their size exceeds 120,000 bytes.
      • cache-headers
        • headers: Adds or overrides response headers.
          • customResponseHeaders: Adds the "Cache-Control" header to responses.
  • services

    • Purpose: Defines backend services and their configuration.
    • Example: my-api-server
      • loadBalancer: Configures the load-balancing behavior for the service.
        • passHostHeader: Controls whether the Host header of incoming requests is forwarded.
          • false: Traefik does not pass the incoming Host header.
        • servers: Specifies the backend server(s) to route traffic to.
          • url: The URL of a backend server (e.g., http://<host>:9003).