upstream kibana {
  server 127.0.0.1:5601 fail_timeout=0;
}
server {
  charset utf-8;

  listen 80;

  server_name {{ kibana_proxy_domain }};

  # Auth.
  include /etc/nginx/snippets/ipaddr_whitelist;
  deny all;
  auth_basic "Reserved {{ kibana_proxy_domain }}";
  auth_basic_user_file /etc/nginx/snippets/private_htpasswd;
  satisfy any;

  location / {
    proxy_redirect off;
    proxy_pass http://kibana/;
    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-Server  $host;
    proxy_set_header    X-Forwarded-Host  $host;
    proxy_set_header    Host  $host;
  }
}
