0

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
  • Please edit your question to explain what "doesn't work" means. Perhaps include verbose curl output showing the current behavior. – EEAA Jul 19 '17 at 13:09

2 Answers2

1

You don't need rewriting the header if you set two Kibana options in kibana.yml:

server.basePath: /kibana

server.rewriteBasePath: true

Apromix
  • 11
  • 1
0

Try this.

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

Test the HAProxy config:

haproxy -c -V -f /etc/haproxy/haproxy.cfg

Restart the HAProxy:

systemctl restart haproxy

The original answer and explanation at: https://stackoverflow.com/questions/36266776/kibana-server-basepath-results-in-404