How to run Kibana with Ngxinx?

Hello,

I have my KIbana and Elasticsearch upp and running on AKS but I'm not relying on Elastic Operator, I'm just deploying everything as I would did with docker-compose.

My services are up and Kibana is running as LoadBalancer svc. When I'm trying to access service IP Address, I get error //ERR_TOO_MANY_REDIRECTS

and the request url, after a while looks like this

http://some-ip-address:5601/app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252Fapp%252525252Fkibana%252525252Flogin%252525253Fnext%252525253D%25252525252Fapp%25252525252Fkibana%25252525252Fapp%25252525252Fkibana%25252525252Flogin%25252525253Fnext%25252525253D%2525252525252Fapp%2525252525252Fkibana%2525252525252Fapp%2525252525252Fkibana%2525252525252Flogin%2525252525253Fnext%2525252525253D%252525252525252Fapp%252525252525252Fkibana%252525252525252Fapp%252525252525252Fkibana%252525252525252Flogin%252525252525253Fnext%252525252525253D%25252525252525252Fapp%25252525252525252Fkibana%25252525252525252Fapp%25252525252525252Fkibana%25252525252525252Flogin%25252525252525253Fnext%25252525252525253D%2525252525252525252Fapp%2525252525252525252Fkibana%2525252525252525252F

I'm not sure why I'm getting this error actually. I was not expecting that ingress will be needed.
Do I have to use nginx? Can someone help me with basic configuration?

I've tried to access kibana as:

http://nginx-svc-ip-address
http://nginx-svc-ip-address/app/kibana

but it does not change anything
I've created some basic nginx setup but it end up with the same errors:

nginx.conf

events { }

http {
    server {
        listen 80;

        location / {
            proxy_pass http://10.0.3.70:5601;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            }
    }
}

logs from nginx:

/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
10.224.0.5 - - [28/Jul/2023:14:07:08 +0000] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:08 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:08 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:09 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:09 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:09 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:09 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252Fapp%252525252Fkibana%252525252Flogin%252525253Fnext%252525253D%25252525252Fapp%25252525252Fkibana%25252525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:10 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252Fapp%252525252Fkibana%252525252Flogin%252525253Fnext%252525253D%25252525252Fapp%25252525252Fkibana%25252525252Fapp%25252525252Fkibana%25252525252Flogin%25252525253Fnext%25252525253D%2525252525252Fapp%2525252525252Fkibana%2525252525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:10 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252Fapp%252525252Fkibana%252525252Flogin%252525253Fnext%252525253D%25252525252Fapp%25252525252Fkibana%25252525252Fapp%25252525252Fkibana%25252525252Flogin%25252525253Fnext%25252525253D%2525252525252Fapp%2525252525252Fkibana%2525252525252Fapp%2525252525252Fkibana%2525252525252Flogin%2525252525253Fnext%2525252525253D%252525252525252Fapp%252525252525252Fkibana%252525252525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:10 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252Fapp%252525252Fkibana%252525252Flogin%252525253Fnext%252525253D%25252525252Fapp%25252525252Fkibana%25252525252Fapp%25252525252Fkibana%25252525252Flogin%25252525253Fnext%25252525253D%2525252525252Fapp%2525252525252Fkibana%2525252525252Fapp%2525252525252Fkibana%2525252525252Flogin%2525252525253Fnext%2525252525253D%252525252525252Fapp%252525252525252Fkibana%252525252525252Fapp%252525252525252Fkibana%252525252525252Flogin%252525252525253Fnext%252525252525253D%25252525252525252Fapp%25252525252525252Fkibana%25252525252525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
10.224.0.5 - - [28/Jul/2023:14:07:10 +0000] "GET /app/kibana/login?next=%2Fapp%2Fkibana%2Fapp%2Fkibana%2Flogin%3Fnext%3D%252Fapp%252Fkibana%252Fapp%252Fkibana%252Flogin%253Fnext%253D%25252Fapp%25252Fkibana%25252Fapp%25252Fkibana%25252Flogin%25253Fnext%25253D%2525252Fapp%2525252Fkibana%2525252Fapp%2525252Fkibana%2525252Flogin%2525253Fnext%2525253D%252525252Fapp%252525252Fkibana%252525252Fapp%252525252Fkibana%252525252Flogin%252525253Fnext%252525253D%25252525252Fapp%25252525252Fkibana%25252525252Fapp%25252525252Fkibana%25252525252Flogin%25252525253Fnext%25252525253D%2525252525252Fapp%2525252525252Fkibana%2525252525252Fapp%2525252525252Fkibana%2525252525252Flogin%2525252525253Fnext%2525252525253D%252525252525252Fapp%252525252525252Fkibana%252525252525252Fapp%252525252525252Fkibana%252525252525252Flogin%252525252525253Fnext%252525252525253D%25252525252525252Fapp%25252525252525252Fkibana%25252525252525252Fapp%25252525252525252Fkibana%25252525252525252Flogin%25252525252525253Fnext%25252525252525253D%2525252525252525252Fapp%2525252525252525252Fkibana%2525252525252525252F HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 

my nginx deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.19.2
        ports:
        - containerPort: 80
        volumeMounts:
        - name: config-volume
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
      volumes:
      - name: config-volume
        configMap:
          name: nginx-config

my kibana.yaml:

  kibana.yml: |
    ## Default Kibana configuration from Kibana base image.
    ## https://github.com/elastic/kibana/blob/master/src/dev/build/tasks/os_packages/docker_generator/templates/kibana_yml.template.js
    #
    server.name: tone-kibana
    server.host: 0.0.0.0

    elasticsearch.hosts: [ "${ELASTICSEARCH_HOSTS}" ]
    monitoring.ui.container.elasticsearch.enabled: true
    server.basePath: /app/kibana

    # X-Pack security credentials

    elasticsearch.username: "kibana_system"
    elasticsearch.password: "${KIBANA_PASSWORD}"
    elasticsearch.ssl.certificateAuthorities: "/usr/share/kibana/config/certs/ca/ca.crt"

Ok, I was able to solve this issue myself. Below you can find nginx.conf which I have used:

events { }

http {
    server {
        listen 80;

        location /app/kibana/ {
            proxy_pass http://10.0.110.19:5601;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;
            }
    }
}

kibana.yml:

    ## Default Kibana configuration from Kibana base image.
    ## https://github.com/elastic/kibana/blob/master/src/dev/build/tasks/os_packages/docker_generator/templates/kibana_yml.template.js
    #
    server.name: tone-kibana
    server.host: 0.0.0.0

    elasticsearch.hosts: [ "${ELASTICSEARCH_HOSTS}" ]
    monitoring.ui.container.elasticsearch.enabled: true
    server.basePath: /app/kibana
    server.rewriteBasePath: true

    # X-Pack security credentials

    elasticsearch.username: "kibana_system"
    elasticsearch.password: "${KIBANA_PASSWORD}"
    elasticsearch.ssl.certificateAuthorities: "/usr/share/kibana/config/certs/ca/ca.crt"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.