我可以使用这个简单的 nginx 配置将其余的通信重定向到 elasticsearch 服务器:
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
client_max_body_size 50M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/nginx/html;
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://localhost:9200;
proxy_set_header Host $host;
}
}
}
如果我尝试将客户端传输协议(protocol)重定向到端口 9300,它不起作用,则客户端无法连接到 Elasticsearch 服务器。
将 tcp 重定向到端口 9300 的正确 nginx 配置是什么?
最佳答案
请注意,如果它是新开发,您应该使用其余客户端,而不是已弃用的传输客户端。
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-transport.html#_tcp_transport
您可能需要设置 set transport.publish_port 和 transport.publish_host...
如果反向代理只是 TCP 代理,它应该可以工作,这里是 nginx on tcp proxy 的文档:
https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/
关于elasticsearch - 如何将 tcp 重定向到 nginx 中 Elasticsearch 服务器的端口 9300?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53284911/