我的设置
Nginx
+ Kibana
- 同一个框不同的域,子域(nginx - example.com,kibana - kibana.example.com)
Elasticsearch
- 192.168.100.31
我使用了下面定义的配置。将 127.0.0.1 替换为Elasticsearch
ip192.168.100.31
https://github.com/elasticsearch/kibana/blob/master/sample/nginx.conf
此设置在本地网络中有效。但在外部连接时失败,浏览器上出现错误消息"Error Could not contact Elasticsearch at http://192.168.100.31:9200. Please ensure that Elasticsearch is reachable from your system."
。
Kibana
config.js
指向 ip 和端口 9200 -
elasticsearch: "http://192.168.100.31:9200",
注意:将此端口更改为匹配nginx
配置中定义的端口8433
可使其stop
正常运行。
nginx config
server {
listen 8443 ssl;
server_name kibana.example.com;
access_log /var/logs/nginx/kibana.access.log main;
error_log /var/logs/nginx/kibana.error.log;
auth_basic "Authorized users";
auth_basic_user_file /file/location/kibana.htpasswd;
location / {
root /usr/local/kibana-3.1.0;
index index.html index.htm;
}
location ~ ^/_aliases$ {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
}
location ~ ^/.*/_aliases$ {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
}
location ~ ^/_nodes$ {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
}
location ~ ^/.*/_search$ {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
}
location ~ ^/.*/_mapping {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
}
# Password protected end points
location ~ ^/kibana-int/dashboard/.*$ {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
limit_except GET {
proxy_pass http://192.168.100.31:9200;
# auth_basic "Restricted";
# auth_basic_user_file /file/location/kibana.htpasswd;
}
}
location ~ ^/kibana-int/temp.*$ {
proxy_pass http://192.168.100.31:9200;
proxy_read_timeout 90;
limit_except GET {
proxy_pass http://192.168.100.31:9200;
# auth_basic "Restricted";
# auth_basic_user_file /file/location/kibana.htpasswd;
}
}
}
nginx
感觉和之间必须有一些代理设置,elasticsearch
以防止本地 IP 显示在浏览器上。有人可以演示如何配置它吗?
答案1
找到解决方案,必须在 nginx 中设置 PROXY,当然还要在 Kibana 的 configs.js 中设置 FQDN 匹配