Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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;                                                                                    
    }                                                                                                                                                          
}                           
share|improve this question

2 Answers 2

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

location /kibana {
    # rewrite before passing to proxy
    rewrite /kibana/(.*) /$1  break;
    proxy_pass      http://127.0.0.1:5601;
    # 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;
    }
}
share|improve this answer

I have one modification on the previous answer.

proxy_pass      http://127.0.0.1:5601;

Replace by

proxy_pass      http://127.0.0.1:5601/;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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