[ 4.3.0 ] how to configure your nginx balancer and apache reverse proxy

problem solved. solution below the question.


could someone please help me reconfigure my nginx balancer?

i have 3 elk nodes behind a UDP/TCP balancer (round-robin).

                   |----------------|
                   |                |
                   |  elk-balancer  |
                   |                |
                   |  80,514,9200   |
                   |----------------|
                           |
        ---------------------------------------
        |                  |                  |
|----------------| |----------------| |----------------|
|                | |                | |                |
|  elk-node-01   | |  elk-node-02   | |  elk-node-03   |
|                | |                | |                |
|----------------| |----------------| |----------------|

since i updated kibana to 4.3.0 , i cant balance kibana web requests anymore.

nginx just hangs there, waiting for for the node to respond... forever...

GET http://elk-balancer/kibana

/var/log/nginx/access-80.log

10.11.12.32 - - [16/Dec/2015:09:41:13 -0200] "GET /kibana/ HTTP/1.1" 200 158 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"

10.11.12.32 - - [16/Dec/2015:09:41:16 -0200] "POST /kibana/elasticsearch/_mget?timeout=0&ignore_unavailable=true&preference=1450266075817 HTTP/1.1" 200 183 "http://10.20.30.160/kibana/app/kibana" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"

10.11.12.32 - - [16/Dec/2015:09:41:16 -0200] "POST /kibana/elasticsearch/.kibana/index-pattern/_search?fields= HTTP/1.1" 403 103 "http://10.20.30.160/kibana/app/kibana" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"

but elasticsearch, logstash, pen and rsyslog are working fine.

ok. got it.

this is what you need for a fully functional proxy / load balancer answering on http://my-balancer/kibana/

#Balancer

nginx

/etc/nginx/conf.d/elastic-80.server.conf

upstream web {

    server elk-node-01;
    server elk-node-02;
    server elk-node-03;

    keepalive 5;
}

server {

    listen 80;

    location / {

        proxy_pass http://web;
        proxy_http_version 1.1;
        proxy_set_header Connection "Keep-Alive";
        proxy_set_header Proxy-Connection "Keep-Alive";
    }

    access_log /var/log/nginx/access-80.log;
    error_log  /var/log/nginx/error-80.log;
}

#Nodes

kibana

/var/www/kibana/config/kibana.yml

# If you are running kibana behind a proxy, and want to mount it at a path,
# specify that path here. The basePath can't end in a slash.
server.basePath: "/kibana"

apache

/etc/apache2/sites-available/15-default.conf

<Location /kibana/>
    ProxyPass http://localhost:5601/
    ProxyPassReverse http://localhost:5601/
</Location>
2 Likes

@yodog,

I tried following your instructions to setup my apache proxy but it is not working for me.

  • Do I need to change any configs to account for the fact that kibana is now rendered at /app/kibana# ? (for ex my try to get kibana mounted at /kibana1/ redirects to /kibana1/app/kibana/ which returns a json with a 404 not found error)
  • I have a bunch of kibana clusters which I want to back behind an alias in apache proxy. How do I do that ?

that is all you need to change.

copy-paste the errors that you are getting, so we can take a look.

@yodog unfortunately It s not working for me.

I m using just nginx as web-server with the following configuration:

server {
    listen       80;
    listen       [::]:80;
    server_name  _;

    location  / {
        uwsgi_pass  django;
        include     /opt/das/webapp/uwsgi_params;
        proxy_http_version 1.1;
    }

    location /kibana/ {
        rewrite /kibana/(.*) /$1 break;
        proxy_pass http://localhost:5601/;
}

The root and elasticsearch are working fine, the problem is with kibana which is redirected to http://host/kibana/app/kibana

1 Like

well...
your config is totally different from the config that i posted.

i could help you if you had tried my config and failed.