Nijo
Nijo

Reputation: 841

Not able to proxy pass AWS Kibana to nginx

I'm using AWS kibana to search and view the logs that Logstash has indexed. Right now i'm using the default URL from AWS and is only restricted to my IP address. I need to proxy_pass it through nginx, i tried to follow this doc: https://sysadmins.co.za/aws-access-kibana-5-behind-elb-via-nginx-reverse-proxy-on-custom-dns/

But kibana is not loading. I'm getting the following error:

Kibana: Not Found
Error: Not Found
    at respond (http://IP/index.js?_b=7562:85344:15)
    at checkRespForFailure (http://IP/index.js?_b=7562:85312:7)
    at http://IP/index.js?_b=7562:83950:7
    at wrappedErrback (http://IP/index.js?_b=7562:20902:78)
    at wrappedErrback (http://IP/index.js?_b=7562:20902:78)
    at wrappedErrback (http://IP/index.js?_b=7562:20902:78)
    at http://IP/index.js?_b=7562:21035:76
    at Scope.$eval (http://IP/index.js?_b=7562:22022:28)
    at Scope.$digest (http://IP/index.js?_b=7562:21834:31)
    at Scope.$apply (http://IP/index.js?_b=7562:22126:24)

Adding Nignx conf:

    server {
      listen 80 default_server;
      listen [::]:80 default_server ipv6only=on;
      server_name kibana.mydomain.com;

      # for elb health checks
      location /status {
        root /usr/share/nginx/html/ ;
      }

      location / {
        proxy_set_header Host search-aws-es.eu-west-1.es.amazonaws.com;
        proxy_set_header X-Real-IP <public-ip-for-instance>;

        proxy_http_version 1.1;
        proxy_set_header Connection "Keep-Alive";
        proxy_set_header Proxy-Connection "Keep-Alive";
        proxy_set_header Authorization "";

        proxy_pass https://search-aws-es.eu-west-1.es.amazonaws.com/_plugin/kibana/;
        proxy_redirect https://search-aws-es.eu-west-1.es.amazonaws.com/_plugin/kibana/ http://<public-ip-for-instance>/kibana/;
      }

      location ~ (/app/kibana|/app/timelion|/bundles|/es_admin|/plugins|/api|/ui|/elasticsearch) {
         proxy_pass              http://search-aws-es.eu-west-1.es.amazonaws.com;
         proxy_set_header        Host $host;
         proxy_set_header        X-Real-IP $remote_addr;
         proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header        X-Forwarded-Proto $scheme;
         proxy_set_header        X-Forwarded-Host $http_host;
    }
  }
}

Upvotes: 4

Views: 2856

Answers (1)

WenWolf
WenWolf

Reputation: 186

On your last location block, add /_plugin/kibana, that fixed it for me.

My working setup (with a VPC based ES but that shouldn't change much as long as you authorize the IP of your proxy within the ES access policy):

server {
  listen       80;
  server_name  kibana.mydomain.com

  location / {
    proxy_http_version 1.1;
    # proxy_set_header Host https://asdfadsfasdfasdf.regionxxx.es.amazonaws.com;
    proxy_set_header Connection "Keep-Alive";
    proxy_set_header Proxy-Connection "Keep-Alive";
    proxy_set_header Authorization "";
    proxy_pass              https://asdfadsfasdfasdf.regionxxx.es.amazonaws.com/_plugin/kibana/;
  }

  location ~ (/_plugin/kibana|/app/kibana|/app/timelion|/bundles|/es_admin|/plugins|/api|/ui|/elasticsearch) {
    proxy_pass              https://asdfadsfasdfasdf.regionxxx.es.amazonaws.com;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_set_header        X-Forwarded-Host $http_host;
    proxy_set_header        Authorization  "";
  }
}

Upvotes: 2

Related Questions