Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

5.7.14. 特定于路由的 IP 白名单

您可以通过在路由中添加 haproxy.router.openshift.io/ip_whitelist 注解来限制对路由集合的访问。白名单是空格分隔的 IP 地址和/或 CIDR 列表,用于批准的源地址。来自白名单以外的 IP 地址的请求会被丢弃。

一些示例:

在编辑路由时,添加以下注解来定义所需的源 IP。或者,使用 oc annotate route <name>

只允许一个特定的 IP 地址:

metadata:
  annotations:
    haproxy.router.openshift.io/ip_whitelist: 192.168.1.10

允许多个 IP 地址:

metadata:
  annotations:
    haproxy.router.openshift.io/ip_whitelist: 192.168.1.10 192.168.1.11 192.168.1.12

允许 IP CIDR 网络:

metadata:
  annotations:
    haproxy.router.openshift.io/ip_whitelist: 192.168.1.0/24

允许混合 IP 地址和 IP CIDR 网络:

metadata:
  annotations:
    haproxy.router.openshift.io/ip_whitelist: 180.5.61.153 192.168.1.0/24 10.0.0.0/8