Code Monkey home page Code Monkey logo

traefik-secpath's Introduction

Traefik Sec Path

Traefik plugin to white list or black list path based on ip.

config

config with dynamic config:

  middlewares:
    secpath:
      plugin:
        secpath:
          rules:
            redir:
              pathRule: ^/re/|/redir/
              ipRule: 172.17.0.1/10,192.168.75.207
              typeRule: redirection
              newPath: /redirect/
            admin:
              pathRule: ^/admin/|^/me/
              ipRule: 172.17.0.1/10,192.168.75.207
              typeRule: fake
              newPath: /fake/
            superadmin:
              pathRule: /super-admin/
              ipRule: 172.20.0.1/24
              typeRule: allow
            megaadmin:
              pathRule: /mega-admin/
              ipRule: 172.20.0.1-172.20.0.255
              typeRule: block

config with docker labels:

  nginx:
    labels:
      - traefik.enable=true
      - traefik.http.routers.nginx.rule=Host(`nginx.local.me`)
      - traefik.http.routers.nginx.entrypoints=web
      - traefik.http.services.nginx.loadbalancer.server.port=80
      # redirect
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.redir.pathRule=^/re/|/redir/
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.redir.ipRule=172.17.0.1/10,192.168.75.207
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.redir.typeRule=redirection
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.redir.newPath=/redirect/
      # allow
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.superadmin.pathRule=/super-admin/
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.superadmin.ipRule=172.20.0.1/24
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.superadmin.typeRule=allow
      # block
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.megaadmin.pathRule=/mega-admin/
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.megaadmin.ipRule=172.20.0.1-172.20.0.255
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.megaadmin.typeRule=block
      # fake
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.admin.pathRule=^/admin/|^/me/
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.admin.ipRule=172.17.0.1/10,192.168.75.207
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.admin.typeRule=fake
      - traefik.http.middlewares.secpath-plugin.plugin.secpath.rules.admin.newPath=/fake/

Path can use regex and should be speparayed by comma (without space)

Ips can be specify by:

  • single ip 172.17.0.1
  • cidr 172.17.0.1/27
  • nmap style 172.17.0.1-172.17.0.255

mulitple ips/range can be specify and need to be comma separated (without space)

4 rules are available:

  • allow
  • block
  • redirect
  • fake

Allow will only allow specify ips to acces path (return unauthorized if not), block will block specify ips to acces path (unauthorized), redirect will redirect specify ip to newPath (newPath should be set).

Fake will fake path ex: user request /admin/ but server while serve /fake-admin/ (url in browser while still show /admin/).

for local testing with docker-compose.yml you should clone this repo to: ./plugins-local/src/github.com/mmpx12/traefik-secpath:

.
├── README.md
├── demo
│   └── html
│       ├── 404.html
│       ├── 50x.html
│       ├── admin
│       │   └── index.html
│       ├── fake
│       │   └── index.html
│       ├── index.html
│       └── redirect
│           └── index.html
├── docker-compose.yml
├── go.mod
├── plugins-local
│   └── src
│       └── github.com
│           └── mmpx12
│               └── traefik-secpath
│                   ├── go.mod
│                   └── secpath.go
└── secpath.go

traefik-secpath's People

Contributors

mmpx12 avatar

Watchers

 avatar

traefik-secpath's Issues

[Traefik Plugin Catalog] Plugin Analyzer has detected a problem.

The plugin was not imported into Traefik Plugin Catalog.

Cause:

failed to load readme: failed to get the readme file: GET https://api.github.com/repos/mmpx12/traefik-secpath/readme?ref=v0.0.1: 404 Not Found []

Traefik Plugin Analyzer will restart when you will close this issue.

If you believe there is a problem with the Analyzer or this issue is the result of a false positive, please fill an issue on piceus repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.