Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I don't fully understand how/where rules are specified #321

Open
ziglotusgithub opened this issue Aug 1, 2022 · 2 comments
Open

I don't fully understand how/where rules are specified #321

ziglotusgithub opened this issue Aug 1, 2022 · 2 comments

Comments

@ziglotusgithub
Copy link

ziglotusgithub commented Aug 1, 2022

I'm attempting to use the rules configuration to allow local subnets to bypass authentication. I have the following:

version: '3.3'
services:
  traefik:
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'
      - './traefik.toml:/traefik.toml'
      - './traefik_dynamic.toml:/traefik_dynamic.toml'
      - './acme.json:/acme.json'
    ports:
      - '80:80'
      - '443:443'
    networks:
      - web
    container_name: traefik
    image: 'traefik:latest'
  traefik-forward-auth:
    image: thomseddon/traefik-forward-auth
    restart: always
    container_name: traefik_auth
    labels:
      - "traefik.http.middlewares.traefik-forward-auth.forwardauth.address=http://traefik-forward-auth:4181"
      - "traefik.http.middlewares.traefik-forward-auth.forwardauth.authResponseHeaders=X-Forwarded-User"
      - "traefik.http.services.traefik-forward-auth.loadbalancer.server.port=4181"
    networks:
      - web
    environment:
      - CLIENT_ID=<redacted>
      - CLIENT_SECRET=<redacted>
      - SECRET=<redacted>
      - WHITELIST=<redacted>
      - LOG_LEVEL=info
      - LIFETIME=604800
      - COOKIE_DOMAIN=<redacted>
      - CONFIG=rules
networks:
  web:
    external: true

As specified above, I use a file called 'rules' with the following:

rule.allow-subnet.action=allow
rule.allow-subnet.rule=HeadersRegexp(`X-Real-Ip`, `^192\.168\.5\.`)

However, that doesn't seem to be applying at all. I don't seem to understand if the rules should be applied here or rather at the docker-compose files for the individual containers and, if so, how/where that works. Please assist.

@chelming
Copy link

you're not mounting your rules file. try something like this

version: '3.3'
services:
  traefik:
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'
      - './traefik.toml:/traefik.toml'
      - './traefik_dynamic.toml:/traefik_dynamic.toml'
      - './acme.json:/acme.json'
    ports:
      - '80:80'
      - '443:443'
    networks:
      - web
    container_name: traefik
    image: 'traefik:latest'
  traefik-forward-auth:
    image: thomseddon/traefik-forward-auth
    restart: always
    container_name: traefik_auth
    labels:
      - "traefik.http.middlewares.traefik-forward-auth.forwardauth.address=http://traefik-forward-auth:4181"
      - "traefik.http.middlewares.traefik-forward-auth.forwardauth.authResponseHeaders=X-Forwarded-User"
      - "traefik.http.services.traefik-forward-auth.loadbalancer.server.port=4181"
    networks:
      - web
    volumes:
      - ${HOME}/docker/traefik-forward-auth/rules:/rules
    environment:
      - CLIENT_ID=<redacted>
      - CLIENT_SECRET=<redacted>
      - SECRET=<redacted>
      - WHITELIST=<redacted>
      - LOG_LEVEL=info
      - LIFETIME=604800
      - COOKIE_DOMAIN=<redacted>
      - CONFIG=/rules
networks:
  web:
    external: true

just update your path in that volumes section

@ziglotusgithub
Copy link
Author

just update your path in that volumes section

Absolute legend mate, that makes total sense and works perfectly. Thanks a million, mate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants