![nginx 负载均衡器和 kafka 休息代理](https://linux22.com/image/154522/nginx%20%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1%E5%99%A8%E5%92%8C%20kafka%20%E4%BC%91%E6%81%AF%E4%BB%A3%E7%90%86.png)
我用Kafka rest proxy
并且我想要behind
load balancer nginx
。我有一个主题cluster Kafka
(三个节点)并使用 JSON 数据生成一条消息
curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" \
--data '{"records":[{"value":{"name": "testUser"}}]}' \
"http://nginx_ip:8080/topics/json_test"
我的 nginx 配置是:
upstream backend {
server 192.168.190.37:8080;
server 192.168.190.38:8080;
server 192.168.190.39:8080;
}
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_redirect off;
proxy_next_upstream timeout;
proxy_connect_timeout 3s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
}
}
我将发送一个请求,postman
但我得到了404
。
192.168.190.1 - - [30/May/2019:13:33:59 -0400] "POST / HTTP/1.1" 404 153 "-" "PostmanRuntime/7.11.0" "-"
但是当我像这样向 ip 服务器发送应用程序时:
curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" \
--data '{"records":[{"value":{"name": "testUser"}}]}' \
"http://192.168.190.37:8080/topics/json_test"
没有问题。如何使用 nginx 负载均衡器来处理 Kafka 休息代理和生产者不同的主题?