Skip to content

Trust of forwarded headers in Traefik #7305

Closed
Closed

Description

@DavidePrincipi

If a NS8 is behind a reverse proxy, its source IP must be trusted for forwarded headers. Furthermore the original client IP must be preserved for logs, authorizations and Crowdsec bans.

See also

Activity

  1. converted this from a draft issue on Feb 10, 2025
  2. moved this from Backlog to In Progress in NethServeron Feb 10, 2025
  3. added this to the NethServer 8.4 milestone on Feb 10, 2025
  4. DavidePrincipi commented on Mar 12, 2025

    @DavidePrincipi
    MemberAuthor

    In testing:

    • core 3.6.0-dev.1
    • traefik 3.0.0-testing.2

    Test case

    Goal: see the issue description

    This feature is currently not exposed in the UI, it can be activated with api-cli.

    Run this command to set the front-end proxy IP:

    api-cli run module/traefik1/set-trusted-proxies --data '{"proxies":["192.168.12.3"]}'
    

    Check the configuration:

    api-cli run module/traefik1/get-trusted-proxies
    

    If the front-end proxy is behind another proxy and so on, use the depth parameter too:

    api-cli run module/traefik1/set-trusted-proxies --data '{"proxies":["192.168.12.3"],"depth":2}'
    

    Verify that:

  5. removed their assignment
    on Mar 12, 2025
  6. added
    testing
    on Mar 12, 2025
  7. moved this from In Progress to Testing in NethServeron Mar 12, 2025
  8. self-assigned this
    on Mar 13, 2025
  9. gsanchietti commented on Mar 13, 2025

    @gsanchietti
    Member

    By default, traefik replaces X-Fowarded-For headers, still it preserve custom headers like X-Forwarded-Custom.

    Tested with a custom traefik route to local echo server, started with:

    podman run --rm -e LOG_HTTP_HEADERS=1 -e LOG_HTTP_BODY=1 --name echo-server -p 10000:8080 docker.io/jmalloc/echo-server
    

    Executing a curl request while trying to forge the X-Forwarded-For:

    curl -k https://rl1.leader.cluster0.gs.nethserver.net/7305 -H "X-Forwarded-For: 192.168.1.1" -H "X-Forwarded-Port: forged" -H "X-Forwarded-Proto: forged" -H "X-Real-Ip: forged"
    

    With default traefik configuration, forwarded headers are:

    X-Forwarded-Custom: 7305
    X-Forwarded-For: 185.96.xx.yy
    X-Forwarded-Host: rl1.leader.cluster0.gs.nethserver.net
    X-Forwarded-Port: 443
    X-Forwarded-Proto: https
    X-Forwarded-Server: rl1.leader.cluster0.gs.nethserver.net
    X-Real-Ip: 185.96.xx.yy
    

    After api-cli run module/traefik1/set-trusted-proxies --data '{"proxies":["185.96.xx.yy"], "depth": 1}'

    X-Forwarded-For: 192.168.1.1, 185.96.130.33
    X-Forwarded-Host: rl1.leader.cluster0.gs.nethserver.net
    X-Forwarded-Port: forged
    X-Forwarded-Proto: forged
    X-Forwarded-Server: rl1.leader.cluster0.gs.nethserver.net
    X-Real-Ip: forged
    

    Current configuration, along with depth field, is correctly returned by the get-trusted-proxies API.

    Verified

  10. added
    verified
    and removed
    testing
    on Mar 13, 2025
  11. removed their assignment
    on Mar 13, 2025
  12. moved this from Testing to In Progress in NethServeron Mar 13, 2025
  13. moved this from In Progress to Verified in NethServeron Mar 13, 2025
  14. moved this from Verified to Done in NethServeron Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    verified

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions