I'm trying to get Kibana to run behind nginx within a specific web directory. Or, put another way, I'm trying to have nginx reverse proxy http://example.com/kibana to http://localhost:5601/, which is where the Kibana sinatra app is running.

I've started Kibana with an init script, and if I curl the localhost url from the server, I get the expected response. However, navigating to http://example.com/kibana/ gives me the message of Sinatra doesn’t know this ditty. and a suggestion that /kibana/ should do something. Presumably, this is a routing issue.

My nginx config is simply this:

server {                                                                                                                                                       
    listen   80; ## listen for ipv4; this line is default and implied                                                                                          
    listen   [::]:80 default ipv6only=on; ## listen for ipv6                                                                                                   

    root /var/www;                                                                                                                                             
    index index.html index.htm;                                                                                                                                

    # Make site accessible from http://localhost/                                                                                                              
    server_name _;                                                                                                                                             

    location / {                                                                                                                                               
        # First attempt to serve request as file, then                                                                                                         
        # as directory, then fall back to index.html                                                                                                           
        try_files $uri $uri/ /index.html;                                                                                                                      
        # Uncomment to enable naxsi on this location                                                                                                           
        # include /etc/nginx/naxsi.rules                                                                                                                       
    location /kibana/ {                                                                                                                                     
        proxy_pass  http://localhost:5601;                                                                                                                     
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;                                                                  
        proxy_redirect off;                                                                                                                                    
        proxy_buffering off;                                                                                                                                   
        proxy_set_header        Host            $host;                                                                                                         
        proxy_set_header        X-Real-IP       $remote_addr;                                                                                                  
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;                                                                                    

2 Answers 2


I have one modification on the previous answer.


Replace by


try this: https://serverfault.com/a/379679/82682 (eventually replace '/foo/Kibana-0.2.0')

location /kibana {
    # rewrite before passing to proxy
    rewrite /kibana/(.*) /$1  break;
    # include nginx' proxy-defaults
    include proxy_params;

    # serve static stuff directly from the static-directory
    location /kibana/favicon.ico {
        alias /foo/Kibana-0.2.0/static/favicon.ico;
    location /kibana/images {
        alias /foo/Kibana-0.2.0/static/images;
    location /kibana/lib {
        alias /foo/Kibana-0.2.0/static/lib;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.