我的 haproxy 配置看起来像这样,并且重定向到 5601 以使 kibana 不起作用。为什么?
##########################################################################
defaults
mode http
log global
option httplog
timeout connect 10s
timeout client 30s
timeout server 30s
frontend http-in
bind *:80
acl main path_beg -i /main
acl kibana path_beg -i /kibana
redirect location main if !main
use_backend kibana-backend if kibana
default_backend application-backend
backend application-backend
mode http
balance leastconn
option httpclose
option forwardfor
stats uri /haproxy?stat
stats enable
cookie JSESSIONID prefix
server app1 172.168.1.1:80 maxconn 32 check inter 5000 cookie my.site.ru
backend kibana-backend
mode http
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
server kibana 172.168.1.2:5601 maxconn 32 check inter 5000 cookie ki.site.ru
答案1
如果您在 kibana.yml 中设置了两个 Kibana 选项,则无需重写标题:
服务器.basePath:/kibana
server.rewriteBasePath:true
答案2
尝试这个。
frontend main *:80
acl url_kibana path_beg -i /kibana
use_backend kibana if url_kibana
backend kibana
mode http
reqrep ^([^\ ]*)\ /kibana[/]?(.*) \1\ /\2
server x.x.x.x:5601
测试 HAProxy 配置:
haproxy -c -V -f /etc/haproxy/haproxy.cfg
重新启动 HAProxy:
systemctl restart haproxy
原答案及解释位于: https://stackoverflow.com/questions/36266776/kibana-server-basepath-results-in-404