Nginx 1.13代理后面的Kibana 5.5.1(dockerized) [英] Kibana 5.5.1 behind a nginx 1.13 proxy (dockerized)
问题描述
目标:
我想在docker容器中运行麋鹿堆栈.为了能够通过nginx代理访问ELK堆栈,以绕过服务的各个端口.
I want to run the elk stack in a docker container. To be able to access the ELK Stack over a nginx proxy to bypass the individual ports for the services.
Kibana服务(默认端口5601)
The Kibana service (default port 5601)
http://<server>.com:5601
应可通过以下地址访问:
should be reachable over the following address:
http://<server>.com/kibana
问题:
问题是,在将server.basePath设置添加到配置后,无法访问kibana站点.仅当我将Kibana的每个基本api调用都添加到nginx配置(/api,/ui,...)时,我才能启动该服务.
The problem is, that it is not possible to reach the kibana site after I add the server.basePath setting to the config. I only can bring up the service if I add every base api call of Kibana to the nginx config (/api, /ui, ...).
配置:
Kibana的配置:
The config for Kibana:
/opt/kibana/config/kibana.yml
具有以下条目:
server.host: "0.0.0.0"
server.basePath: "/kibana"
所有其他默认设置
Doku server.basePath
# Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects
# the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests
# to Kibana. This setting cannot end in a slash.
nginx配置:
location /kibana/ {
rewrite ^/kibana(/.*)$ $1 break;
proxy_pass http://<server>.com:5601/;
}
我使用 sebp/elk:551 泊坞窗映像和以下泊坞窗-撰写文件:
I use the sebp/elk:551 docker image and the following docker-compose file:
version: '2'
services:
elk:
image: sebp/elk:551
container_name: "elk"
volumes:
- /etc/kibana/config/kibana.yml:/opt/kibana/config/kibana.yml
ports:
- "5601:5601"
- "9200:9200"
- "5044:5044"
environment:
SERVICE_5601_NAME: "kibana"
SERVICE_9200_NAME: "elasticsearch"
SERVICE_5044_NAME: "logstash"
restart: always
我尝试过的事情:
我已经尝试过使用Kibana 4.6.1进行相同的设置,并且可以按预期运行.
I have tried the same setup with Kibana 4.6.1 and it worked perfectly as expected.
我已测试但无法使用的版本:5.4.3、5.1.2、5.0.2
Versions that I have tested and do not work: 5.4.3, 5.1.2, 5.0.2
我不想要的内容:
我不想像/api, /ui, /app/kibana, ...
一样添加Kibana的每个子目录来添加到代理配置中.
I dont want to add every subdirectory of Kibana like /api, /ui, /app/kibana, ...
to add to the proxy config.
还有其他解决方案或版本吗?
Is there an other solution or version?
@ whites11:浏览器从nginx返回502 Bad Gateway站点. 浏览器信息:
@whites11: The browser return the 502 Bad Gateway site from nginx. Browser infos:
常规
Request URL:http://<server-name>.com/kibana/
Request Method:GET
Status Code:502 Bad Gateway
Remote Address:<server-ip>:80
Referrer Policy:no-referrer-when-downgrade
响应标题
Connection:keep-alive
Content-Length:575
Content-Type:text/html
Date:Thu, 24 Aug 2017 13:54:49 GMT
Server:nginx/1.13.3
请求标头
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:<server-name>.com
Upgrade-Insecure-Requests:1
从nginx登录
34#34: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: <IP>, server: , request: "GET /kibana/ HTTP/1.1", upstream: "http://<server-ip>:5601/", host: "<server-name>.com"
推荐答案
我的部署与您没有完全相同的部署,但是我使用的是dockerized基巴纳语.
I don't have exactly the same deployment as you do, but I am using a dockerized kibana.
首先,您需要在nginx设置中进行以下操作:
First of all, you need the following in your nginx settings:
location /kibana/ {
proxy_pass http://kibana_server:5601/;
}
根据您的环境更改值,但最后的斜杠至关重要!不要删除它们!他们确保重写按Kibana的预期进行-即,在转到kibana服务器的请愿书中,将kibana
从URL中删除.
Change the values according to your environment, but the final slashes are critical! Don't remove them! They ensure that the rewriting is done as expected by Kibana --i.e., the kibana
is removed from the URL in the petition that goes to the kibana server.
然后保持以下内容:
server.basePath: /kibana
在您的kibana设置中.这样可以确保kibana提供的文档(链接和URL)具有前缀/kibana
.
in your kibana settings. That ensures that the documents provided by kibana (links and urls) have the prefix /kibana
.
对我有用.
这篇关于Nginx 1.13代理后面的Kibana 5.5.1(dockerized)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!