I have to manage and create two location nginx that point to the same upstream Kibana application, one with authentication and the other without authentication but I'm stuck here at this point. my config below:
nginx.conf
upstream kibana_backend {
server 192.168.1.20:5601;
}
server {
listen 80 default_server;
location / {
if ($scheme = 'http') {
rewrite ^ https://$http_host$request_uri? permanent;
}
}
listen 443 ssl;
server_name tool.example.com;
location ^~/without_authentication/app/kibana/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header Host $host;
rewrite ^/without_authentication(.*) /$1 break;
proxy_pass http://kibana_backend;
}
location ^~/with_authentication/app/kibana/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
auth_basic
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_set_header Host $host;
rewrite ^/with(.*) /$1 break;
proxy_pass http://kibana_backend;
}
kibana.yaml
server.publicBaseUrl: "https://tool.example.com/app/kibana"
server.basePath: "/app/kibana"
If I want to access https://tool.example.com/with_authentication/app/kibana doesn't do nothing.