# Nginx on ES/Kibana machine

**URL:** https://discuss.elastic.co/t/nginx-on-es-kibana-machine/123168
**Category:** Elasticsearch
**Created:** [March 9, 2018, 12:30am UTC](https://discuss.elastic.co/t/nginx-on-es-kibana-machine/123168 "2018-03-09T00:30:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)
#### Post date: [March 9, 2018, 12:30am UTC](https://discuss.elastic.co/t/nginx-on-es-kibana-machine/123168/1 "2018-03-09T00:30:26Z")

</div>

Hi guys,

I've been trying every combination to make this work and after many hours, I've come here to post my config for anyone in the future because it was hard to find any documentation about it.

I'm setting up nginx on a machine with both kibana and ES on it (I know for prod that's not great). And it's difficult to get nginx to properly redirect both ES and kibana when they are on the same machine. But alas, I figured it out with the help of [this post](https://discuss.elastic.co/t/reverse-proxy-kibana/43647/14?u=tsullivan)

kib.yml  
`server.basePath:"/kibana"`

nginx

```auto
server {
    listen 80;

    #server_name http://yourwebsitename.com;

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/htpasswd.users;

    location ~ ^/kibana/(.*)$ {
        rewrite /kibana/(.*) /$1 break;
        proxy_pass http://localhost:5601;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    location / {
        proxy_pass http://localhost:9200;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 6, 2018, 12:30am UTC](https://discuss.elastic.co/t/nginx-on-es-kibana-machine/123168/2 "2018-04-06T00:30:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
