Nginx
配置 Nginx、Kibana、Elasticsearch
我的設置
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顯示在瀏覽器上。有人可以展示如何配置它。
找到解決方案,必須在 nginx 中設置 PROXY,當然還要在 Kibana 的 configs.js 中設置 FQDN 匹配