<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          使用 Traefik 中間件處理 Log4J 漏洞

          共 2220字,需瀏覽 5分鐘

           ·

          2021-12-25 05:37

          Traefik 的中間件是最讓人喜歡的一個(gè)功能,為了能夠擴(kuò)展中間件,Traefik 官方還推出了 Pilot(https://pilot.traefik.io/) 這樣的中間件 SaaS 服務(wù),和 Traefik 深度集成,我們可以非常方便的使用平臺上提供的各種中間件,在 Dashboard 上就可以無縫進(jìn)行對接:

          Log4Shell(https://github.com/traefik/plugin-log4shell) 就是一個(gè)解決最近很火的 Log4J 漏洞的 Traefik 插件,相關(guān)介紹:https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228。不過要使用該中間件需要 Traefik >= v.2.5.5 版本。

          使用也是非常簡單的,首先通過靜態(tài)配置啟用該插件,可以通過 Traefik 啟動參數(shù)配置:

          --pilot.token=xxx??#?去?pilot?注冊實(shí)例獲取的?token
          --experimental.plugins.log4shell.modulename=github.com/traefik/plugin-log4shell
          --experimental.plugins.log4shell.version=v0.1.2

          或者配置文件:

          pilot:
          ??token:?xxx

          experimental:
          ??plugins:
          ????log4shell:
          ??????modulename:?github.com/traefik/plugin-log4shell
          ??????version:?v0.1.2

          為了使用 Log4Shell 插件我們首先需要?jiǎng)?chuàng)建一個(gè)中間件,比如在 Kubernetes 系統(tǒng)中,只需要?jiǎng)?chuàng)建如下所示的資源對象即可:

          apiVersion:?traefik.containo.us/v1alpha1
          kind:?Middleware
          metadata:
          ??name:?log4shell-foo
          spec:
          ??plugin:
          ????log4shell:
          ??????errorCode:?200

          然后在 IngressRoute 中關(guān)聯(lián)上上面的中間件即可修復(fù):

          apiVersion:?traefik.containo.us/v1alpha1
          kind:?IngressRoute
          metadata:
          ??name:?whoami
          spec:
          ??entryPoints:
          ????-?web
          ??routes:
          ????-?kind:?Rule
          ??????match:?Host(`whoami.localhost`)
          ??????middlewares:
          ????????-?name:?log4shell-foo
          ??????services:
          ????????-?kind:?Service
          ??????????name:?whoami-svc
          ??????????port:?80

          當(dāng)然如果使用的是默認(rèn)的 Ingress 資源對象,則需要通過 annotation 注解來配置:

          apiVersion:?networking.k8s.io/v1
          kind:?Ingress
          metadata:
          ??name:?myingress
          ??annotations:
          ????traefik.ingress.kubernetes.io/router.middlewares:?default-log4shell-foo@kubernetescrd
          spec:
          ??ingressClassName:?traefik
          ??rules:
          ????-?host:?whoami.localhost
          ??????http:
          ????????paths:
          ??????????-?path:?/
          ????????????pathType:?Prefix
          ????????????backend:
          ??????????????service:
          ????????????????name:??whoami
          ????????????????port:
          ??????????????????number:?80

          同樣如果是使用 Docker 環(huán)境則需要通過 labels 標(biāo)簽進(jìn)行配置:

          version:?'3.7'

          services:
          ??whoami:
          ????image:?traefik/whoami:v1.7.1
          ????labels:
          ??????traefik.enable:?'true'
          ??????traefik.http.routers.app.rule:?Host(`whoami.localhost`)
          ??????traefik.http.routers.app.entrypoints:?websecure
          ??????traefik.http.routers.app.middlewares:?log4shell-foo
          ??????traefik.http.middlewares.log4shell-foo.plugin.log4shell.errorcode:?200
          瀏覽 51
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  免费日屄| 欧美日韩在线手机 | 亚洲日韩一区二区三区四区丨高清 | 奇米狠狠777 | 久久精品五月天 |