My haproxy config looks like and redirect to 5601 for kibana doesn't work.
Why?
##########################################################################
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
Best Answer
You don't need rewriting the header if you set two Kibana options in kibana.yml:
server.basePath: /kibana
server.rewriteBasePath: true