百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

kafka-proxy

> 安全
开源

与 Kafka 集群的代理连接。通过 SOCKS 代理、HTTP 代理或运行在 Kubernetes 中的集群进行连接。

629 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

与 Kafka 集群的代理连接。通过 SOCKS 代理、HTTP 代理或运行在 Kubernetes 中的集群进行连接。

kafka-proxy

The Kafka Proxy is based on idea of Cloud SQL Proxy. It allows a service to connect to Kafka brokers without having to deal with SASL/PLAIN authentication and SSL certificates.

It works by opening tcp sockets on the local machine and proxying connections to the associated Kafka brokers when the sockets are used. The host and port in Metadata and FindCoordinator responses received from the brokers are replaced by local counterparts. For discovered brokers (not configured as the boostrap servers), local listeners are started on random ports. The dynamic local listeners feature can be disabled and an additional list of external server mappings can be provided.

The Proxy can terminate TLS traffic and authenticate users using SASL/PLAIN. The credentials verification method is configurable and uses golang plugin system over RPC.

The proxies can also authenticate each other using a pluggable method which is transparent to other Kafka servers and clients. Currently, the Google ID Token for service accounts is implemented i.e. proxy client requests and sends service account JWT and proxy server receives and validates it against Google JWKS.

Kafka API calls can be restricted to prevent some operations e.g. topic deletion or produce requests.

See:

  • Kafka Proxy with Amazon MSK
  • A Guide To The Kafka Protocol
  • Kafka protocol guide

Supported Kafka versions

Following table provides overview of supported Kafka versions (specified one and all previous Kafka versions). As not every Kafka release adds new messages/versions which are relevant to the Kafka proxy, newer Kafka versions can also work.

Kafka proxy version Kafka version
from 0.11.0
0.2.9 to 2.8.0
0.3.1 to 3.4.0
0.3.11 to 3.7.0
0.3.12 to 3.9.0
0.4.2 to 4.0.0

Install binary release

  1. Download the latest release

    Linux

    bash
     curl -Ls https://github.com/grepplabs/kafka-proxy/releases/download/v0.4.3/kafka-proxy-v0.4.3-linux-amd64.tar.gz | tar xz

    macOS

    bash
     curl -Ls https://github.com/grepplabs/kafka-proxy/releases/download/v0.4.3/kafka-proxy-v0.4.3-darwin-amd64.tar.gz | tar xz
    
  2. Move the binary in to your PATH.

    bash
    sudo mv ./kafka-proxy /usr/local/bin/kafka-proxy

Building

make clean build

Docker images

Docker images are available on Docker Hub.

You can launch a kafka-proxy container for trying it out with

bash
docker run --rm -p 30001-30003:30001-30003 grepplabs/kafka-proxy:0.4.3 \
          server \
        --bootstrap-server-mapping "localhost:19092,0.0.0.0:30001" \
        --bootstrap-server-mapping "localhost:29092,0.0.0.0:30002" \
        --bootstrap-server-mapping "localhost:39092,0.0.0.0:30003" \
        --dial-address-mapping "localhost:19092,172.17.0.1:19092" \
        --dial-address-mapping "localhost:29092,172.17.0.1:29092" \
        --dial-address-mapping "localhost:39092,172.17.0.1:39092" \
        --debug-enable

Kafka-proxy will now be reachable on localhost:30001, localhost:30002 and localhost:30003, connecting to kafka brokers running in docker (network bridge gateway 172.17.0.1) advertising PLAINTEXT listeners on localhost:19092, localhost:29092 and localhost:39092.

Docker images with precompiled plugins

Docker images with precompiled plugins located in /opt/kafka-proxy/bin/ are tagged with -all.

You can launch a kafka-proxy container with auth-ldap plugin for trying it out with

bash
docker run --rm -p 30001-30003:30001-30003 grepplabs/kafka-proxy:0.4.3-all \
              server \
            --bootstrap-server-mapping "localhost:19092,0.0.0.0:30001" \
            --bootstrap-server-mapping "localhost:29092,0.0.0.0:30002" \
            --bootstrap-server-mapping "localhost:39092,0.0.0.0:30003" \
            --dial-address-mapping "localhost:19092,172.17.0.1:19092" \
            --dial-address-mapping "localhost:29092,172.17.0.1:29092" \
            --dial-address-mapping "localhost:39092,172.17.0.1:39092" \
            --debug-enable \
            --auth-local-enable  \
            --auth-local-command=/opt/kafka-proxy/bin/auth-ldap  \
            --auth-local-param=--url=ldap://172.17.0.1:389  \
            --auth-local-param=--start-tls=false \
            --auth-local-param=--bind-dn=cn=admin,dc=example,dc=org  \
            --auth-local-param=--bind-passwd=admin  \
            --auth-local-param=--user-search-base=ou=people,dc=example,dc=org  \
            --auth-local-param=--user-filter="(&(objectClass=person)(uid=%u)(memberOf=cn=kafka-users,ou=realm-roles,dc=example,dc=org))"

Help output

Run the kafka-proxy server

Usage:
  kafka-proxy server [flags]

  Flags:
        --auth-gateway-client-command string                   Path to authentication plugin binary
        --auth-gateway-client-enable                           Enable gateway client authentication
        --auth-gateway-client-log-level string                 Log level of the auth plugin (default "trace")
        --auth-gateway-client-magic uint                       Magic bytes sent in the handshake
        --auth-gateway-client-method string                    Authentication method
        --auth-gateway-client-param stringArray                Authentication plugin parameter
        --auth-gateway-client-timeout duration                 Authentication timeout (default 10s)
        --auth-gateway-server-command string                   Path to authentication plugin binary
        --auth-gateway-server-enable                           Enable proxy server authentication
        --auth-gateway-server-log-level string                 Log level of the auth plugin (default "trace")
        --auth-gateway-server-magic uint                       Magic bytes sent in the handshake
        --auth-gateway-server-method string                    Authentication method
        --auth-gateway-server-param stringArray                Authentication plugin parameter
        --auth-gateway-server-timeout duration                 Authentication timeout (default 10s)
        --auth-local-command string                            Path to authentication plugin binary
        --auth-local-enable                                    Enable local SASL/PLAIN authentication performed by listener - SASL handshake will not be passed to kafka brokers
        --auth-local-log-level string                          Log level of the auth plugin (default "trace")
        --auth-local-mechanism string                          SASL mechanism used for local authentication: PLAIN or OAUTHBEARER (default "PLAIN")
        --auth-local-param stringArray                         Authentication plugin parameter
        --auth-local-timeout duration                          Authentication timeout (default 10s)
        --bootstrap-server-mapping stringArray                 Mapping of Kafka bootstrap server address to local address (host:port,host:port(,advhost:advport))
        --debug-enable                                         Enable Debug endpoint
        --debug-listen-address string                          Debug listen address (default "0.0.0.0:6060")
        --default-listener-ip string                           Default listener IP (default "0.0.0.0")
        --deterministic-listeners                              Enable deterministic listeners (listener port = min port + broker id).
        --dial-address-mapping stringArray                     Mapping of target broker address to new one (host:port,host:port). The mapping is performed during connection establishment
        --dynamic-advertised-listener string                   Advertised address for dynamic listeners. If left empty, default-listener-ip is used. Supports templating with {{.brokerId}} for dynamic hostnames and a fixed port if provided.
        --dynamic-listeners-disable                            Disable dynamic listeners.
        --dynamic-sequential-min-port int                      If set to non-zero, makes the dynamic listener use a sequential port starting with this value rather than a random port every time.
        --external-server-mapping stringArray                  Mapping of Kafka server address to external address (host:port,host:port). A listener for the external address is not started
        --forbidden-api-keys ints                              Forbidden Kafka request types. The restriction should prevent some Kafka operations e.g. 20 - DeleteTopics
        --forward-proxy string                                 URL of the forward proxy. Supported schemas are socks5 and http
        --gssapi-auth-type string                              GSSAPI auth type: KEYTAB or USER (default "KEYTAB")
        --gssapi-disable-pa-fx-fast                            Used to configure the client to not use PA_FX_FAST.
        --gssapi-keytab string                                 krb5.keytab file location
        --gssapi-krb5 string                                   krb5.conf file path, default: /etc/krb5.conf (default "/etc/krb5.conf")
        --gssapi-password string                               Password for auth type USER
        --gssapi-realm string                                  Realm
        --gssapi-servicename string                            ServiceName (default "kafka")
        --gssapi-spn-host-mapping stringToString               Mapping of Kafka servers address to SPN hosts (default [])
        --gssapi-username string                               Username (default "kafka")
    -h, --help                                                 help for server
        --http-disable                                         Disable HTTP endpoints
        --http-health-path string                              Path on which to health endpoint (default "/health")
        --http-listen-address string                           Address that kafka-proxy is listening on (default "0.0.0.0:9080")
        --http-metrics-path string                             Path on which to expose metrics (default "/metrics")
        --kafka-client-id string                               An optional identifier to track the source of requests (default "kafka-proxy")
        --kafka-connection-read-buffer-size int                Size of the operating system's receive buffer associated with the connection. If zero, system default is used
        --kafka-connection-write-buffer-size int               Sets the size of the operating system's transmit buffer associated with the connection. If zero, system default is used
        --kafka-dial-timeout duration                          How long to wait for the initial connection (default 15s)
        --kafka-keep-alive duration                            Keep alive period for an active network connection. If zero, keep-alives are disabled (default 1m0s)
        --kafka-max-open-requests int                          Maximal number of open requests pro tcp connection before sending on it blocks (default 256)
        --kafka-read-timeout duration                          How long to wait for a response (default 30s)
        --kafka-write-tim

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gokafkakafka-gatewaykafka-proxyoauthbearer

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类安全
定价开源

> 相关工具

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.