Bookmarks

    Nothing saved yet. Use the bookmark on any article. Bookmarks are kept on this device only: they stay private and work without an account.

    Settings

    Appearance

    Reading mode

    Font size

    Content width

    Line spacing

    Keyboard shortcuts

    /
    Search
    j k
    Next / previous story
    ← →
    Previous / next section (columns)
    b
    Bookmarks
    s
    Settings
    r
    Columns / scroll
    t
    Light / dark

    Saved in this browser only.

    Ping2Prompt
    Subscribe to the Weekly Brief Sign in
    A network switch with numbered Ethernet ports, with grey and blue LAN cables plugged into several of them.
    Photo by Jonathan on Unsplash

    Traefik: close api.insecure and put the dashboard behind authentication

    Automated source check Documentation reviewed

    Traefik

    The default

    Here is the setting to look for in your own files. The api.insecure option switches on the API and the dashboard on the entryPoint named traefik. It defaults to false, so someone has to turn it on.

    Separately, setting api to true also turns on the dashboard, which itself defaults to true. We have no data on how common this is in copied files, so check yours rather than assume.

    Why it bites

    The dashboard is a page that pulls its data from the API. That API describes your routers, services, middlewares and similar objects. According to the docs, enabling it will "expose all configuration elements, including sensitive data."

    The docs say enabling it in production is not recommended. Reading it takes nothing special, because the endpoints answer plain GET requests. Documented paths cover HTTP routers, services and middlewares, with matching TCP paths.

    The vendor says not to expose the API port publicly and to keep it on internal networks. If you do run it in production, the docs say to secure it with authentication and authorizations at the least. On a flat LAN or a loosely isolated VLAN, internal can include more machines than you think.

    We could not confirm from our sources whether insecure mode asks for any login. Route and middleware names alone can map your services for anyone who reads them.

    How to check

    First, search your compose files and static config for the option by running grep -rn 'api.insecure' . in your stacks folder (verify before running). Next, from a different machine on the network, request the router list with curl -s http://TRAEFIK_HOST:PORT/api/http/routers (verify before running). Use the port of your traefik entryPoint, because our sources do not state its default.

    If JSON comes back, that machine can read your router configuration. Repeat the same curl form for /api/http/services and /api/http/middlewares (verify before running). We could not confirm an /api/rawdata endpoint in the docs, so test the documented paths instead.

    Also look for a router that uses the api@internal service, and see whether it lists a middlewares entry. If you enabled api.debug, extra debugging and profiling endpoints are on as well.

    The fix

    Set api.insecure to false or remove it, since false is already the default. The cost is that the dashboard no longer appears on the traefik entryPoint, so you have to route it yourself. The documented pattern is a router with a Host rule plus PathPrefix for /api or /dashboard, the service api@internal, and a middlewares entry pointing at a basicAuth middleware.

    In Docker labels, that means setting the dashboard router's service to api@internal and its middlewares to auth. basicAuth passwords must be hashed with MD5, SHA1 or BCrypt, and htpasswd can generate them. Passwords longer than 1024 bytes are rejected. In compose labels, double every dollar sign in the hash, and generate the pair with htpasswd -nB user (verify before running).

    Do not double them where compose does not evaluate the value, such as the Ansible docker_container module. On Kubernetes, use the secret field instead of users or usersFile. According to the docs, a basic-auth secret stores the username and password unhashed, which they call "less secure than other methods."

    If you copy the Helm example, note that it uses the websecure entryPoint and a placeholder admin and changeme login. The docs tell you to replace that password. Keep the API port off public networks as well.

    Our sources do not cover forward-auth, so we give no steps for it. The ongoing cost is one hashed credential to manage and a hostname to remember.

    Friday checklist

    Search every compose file and config for insecure mode. Request the API from a second host and confirm it no longer answers. Put the dashboard behind authentication with a properly hashed password. Replace any placeholder login you copied from an example.

    Sources

    Image: Photo by Jonathan on Unsplash


    This story was produced with AI assistance from the sources listed above and fact-checked against them before publication. Read our editorial methodology and the corrections log. Spotted an error? Email [email protected].

    Continue

    Share on Bluesky · Mastodon · Email ·

    Discussion