LoginSignup
0
0

More than 1 year has passed since last update.

traefikにIPアドレスの制限(ホワイトリスト)を設定する

Posted at

上記の設定が出来ていることが前提となります。

■docker-compose-app.yml

docker-compose-app.yml
# 変更前
      - traefik.enable=true
      - traefik.docker.network=docker-network
      - traefik.http.middlewares.app-https-redirect.redirectscheme.scheme=https
docker-compose-app.yml
# 変更後
      - traefik.enable=true
      - traefik.docker.network=docker-network
      - traefik.http.middlewares.app-https-redirect.redirectscheme.scheme=https
      # 制限の設定を追加
      # IP制限を使用する場合「testIPwhitelist」を指定します
      - traefik.http.middlewares.testIPwhitelist.ipwhitelist.sourcerange=127.0.0.1/32,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16

      # 「testIPwhitelist」を使用
      - traefik.http.routers.test-app-test-secure.middlewares=testIPwhitelist

■ホワイトリストについて

上記の1ファイルを少し変更するだけで対応できます。
カンマ区切りで複数のIPアドレスの範囲を指定することができます。

「X-Forwarded-For」を参照する必要がある場合、下記の設定が必要になります。 「traefik.http.middlewares.testIPwhitelist.ipwhitelist.ipstrategy.depth=【何番目を参照するか】」

■関連記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0