Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

By updated

Improve this page

Traefik logo

Protecting an entry point means preventing unauthorized access, reducing abuse and limiting the impact of a compromise. Traefik places protections around applications through middlewares and administration settings. This lesson distinguishes their roles and shows how to verify them without confusing a setting that is present with protection that is actually applied.

What you will learn

These objectives distinguish protection for public traffic from measures that reduce exposure of the administration interface and Docker engine.

  • Distinguish authentication, source-address filtering and rate limiting.
  • Explain what security headers do and where their limits are.
  • Keep the API and dashboard behind protected access.
  • Reduce the rights given to the Docker provider by isolating socket access.

Prerequisites

This lesson builds on Traefik routing objects and the way the Docker provider discovers containers.

Security in layers

An exposed reverse proxy faces continuous scans, brute-force attempts and rate abuse. No single protection is enough; combine layers.

LayerMiddleware or settingThreat addressed
AuthenticationbasicAuth, forwardAuthUnauthorized access
RaterateLimitBrute force, application-level denial of service
OriginipAllowListExposure of administration interfaces
ResponseheadersClickjacking, XSS, MIME sniffing
TransportTLSProtecting exchanges between client and proxy

A measure only applies to the route it is attached to. Check the real request path and observed responses, not just whether an object exists in the configuration.

Authentication

BasicAuth

BasicAuth asks for a username and secret on every request. It can suit a small internal interface when the connection is encrypted. Do not write the secret in clear text to a file tracked by Git. In Docker Compose, special characters in a hash must also be protected from interpolation.

ForwardAuth: delegate to an SSO

ForwardAuth delegates the authentication decision to an external service. Traefik forwards the request to it and allows access only if the service returns 2xx. This is how SSO portals such as Authelia or OAuth2 Proxy can rely on an identity provider such as Keycloak (in French).

The authentication service makes the decision; the application can then consume explicitly allowed identity headers. Trust those headers only when they come from the expected proxy. Deploying and managing the identity provider is outside this lesson; see Identity management (in French).

MethodSSOMFAUse case
BasicAuthNoNoDevelopment, internal tools
ForwardAuthYesDepends on the identity providerProduction, centralized SSO

To choose and deploy an identity provider, see the Identity management hub (in French).

Rate limiting

The rateLimit middleware controls request frequency using a grouping source and allows a bounded burst. It can slow abuse against a route, but does not replace network capacity or protection against volumetric denial of service. Set thresholds based on legitimate traffic: a limit that is too low blocks normal users, while one that is too high provides little protection.

IP filtering

ipAllowList restricts access to known address ranges. Use it when an administration interface or back office should be limited to approved networks.

A request whose source address does not match the policy is rejected. If an upstream proxy sits in front of Traefik, the visible address may belong to that proxy. Read X-Forwarded-For only from trusted proxies.

Security headers

The headers middleware adds headers that protect the client's browser: anti-clickjacking, anti-MIME-sniffing and content policy.

Header familyThreat addressed
HSTSAccidental browser return to HTTP
Content policyUnexpected resource or script loading
Protection against frame embeddingDeceptive display inside another site
Content-type policyUnexpected interpretation of a response
Referrer policyExcessive disclosure of navigation information

The right values depend on the application. An overly strict policy can break legitimate resources; check the application's behavior before enforcing a general policy.

CORS

Cross-origin requests are also configured through headers, with accessControlAllowOriginList, accessControlAllowMethods and accessControlAllowHeaders. Restrict allowed origins: with *, any website can read responses to CORS requests without credentials. CORS does not replace API authentication.

Strengthen TLS options

Beyond certificates, enforce a minimum transport security level. Define a TLSOption with a minimum TLS 1.2 version and modern cipher suites.

TLS versions and cipher suites are configured separately from middlewares. Choose the minimum based on required compatibility and organizational security policy. For certificate configuration, see Traefik and automatic HTTPS with ACME.

Secure the dashboard

The Traefik dashboard reveals your routing topology. Never expose it with --api.insecure=true in production. Put it behind a protected route: HTTPS, plus BasicAuth or ForwardAuth, plus IP filtering.

The dashboard and API expose administrative information. Direct access is only for an isolated local environment. In a deployment, close direct access and make administration available only through an explicitly protected route. Check that the API and dashboard follow the same access policy.

Secure the Docker socket

The Docker socket provides access to the host control API. Mounting it read-only does not make Docker API requests harmless: the mounted file is still a path to the daemon. Use a socket proxy that exposes only the operations Traefik needs and keep it on an internal network. The Docker socket proxy (in French) lesson explains this mechanism.

Production hardening checklist

A security review checks each layer and its effect on a real request. Use the points below as review questions, not as a universal configuration to copy.

  1. Encrypt traffic from the client to the entry point and check the behavior of the HTTP redirect.

  2. Keep the dashboard closed: never use insecure; always put it behind authentication and TLS, adding IP filtering when source networks can be restricted.

  3. Limit the Docker API available to the provider to what it strictly needs.

  4. Apply security headers globally on public entrypoints.

  5. Use rate limiting and IP filtering on sensitive routes (administration, API).

  6. Follow product security advisories and review changes during upgrades.

Troubleshooting

A symptom suggests which layer to examine first. Confirm the hypothesis with the actual response and logs before changing a setting.

SymptomLikely causeFix
HSTS is absentTesting over HTTPHSTS is sent only over HTTPS
A legitimate user is blockedRate threshold is too strictCompare it with normal load before changing the policy
Unexpected source addressTraefik receives a connection from an upstream proxyDeclare trusted proxies explicitly before reading forwarded headers

Practice

The lab asks you to reduce exposure of an administration endpoint and the Docker provider, then check behavior from an authorized and an unauthorized client. The scenario supplies the environment details and success criteria; this lesson explains the risks and protection families without giving you a ready-to-copy configuration.

Key points

These controls complement each other: security depends on their actual application, not just their presence in a file.

  • Traefik protects services with complementary layers but does not replace application controls.
  • BasicAuth suits restricted use; ForwardAuth delegates a decision to an identity service.
  • Adapt filtering and rate limits to the source and legitimate traffic.
  • Headers strengthen browser behavior; HSTS applies to an HTTPS connection.
  • Do not expose the dashboard without protection or mount the raw Docker socket.

Knowledge check

The quiz covers the role and limits of the main protections.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
8 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn