kafka-proxy

Description

The kafka-proxy plugin can be used to configure advanced parameters for the kafka upstream of Apache APISIX, such as SASL authentication.

Attributes

NameTypeRequiredDefaultValid valuesDescription
saslobjectoptional{“username”: “user”, “password” :”pwd”}SASL/PLAIN authentication configuration, when this configuration exists, turn on SASL authentication; this object will contain two parameters username and password, they must be configured.
sasl.usernamestringrequiredSASL/PLAIN authentication username
sasl.passwordstringrequiredSASL/PLAIN authentication password
kafka-proxy - 图1note

If SASL authentication is enabled, the sasl.username and sasl.password must be set. The current SASL authentication only supports PLAIN mode, which is the username password login method.

Example usage

When we use scheme as the upstream of kafka, we can add kafka authentication configuration to it through this plugin.

  1. curl -X PUT 'http://127.0.0.1:9180/apisix/admin/routes/r1' \
  2. -H 'X-API-KEY: <api-key>' \
  3. -H 'Content-Type: application/json' \
  4. -d '{
  5. "uri": "/kafka",
  6. "plugins": {
  7. "kafka-proxy": {
  8. "sasl": {
  9. "username": "user",
  10. "password": "pwd"
  11. }
  12. }
  13. },
  14. "upstream": {
  15. "nodes": {
  16. "kafka-server1:9092": 1,
  17. "kafka-server2:9092": 1,
  18. "kafka-server3:9092": 1
  19. },
  20. "type": "none",
  21. "scheme": "kafka"
  22. }
  23. }'

Now, we can test it by connecting to the /kafka endpoint via websocket.

Disable Plugin

To disable the kafka-proxy Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.