How to setup Nginx proxy for Kibana with Amazon ElasticSearch and 2 factor auth.
Amazon ElasticSearch comes re-built with Kibana, the problem is that the url is not friendly and you can not customize it for your domain.
First we’ll setup a proxy for authentication with 2 factor such as Google or Github.
Download the Prebuilt Binary of bit.ly oauth2_proxy binary.
Configure it via config file:
Here’s how to set a google client id and secret
https://github.com/bitly/oauth2_proxy#google-auth-provider
The cookie_secret is just a random string base64 encoded.
Once you have the config file ready run the bit.ly proxy:
`oauth2_proxy -config oauth2_proxy.cfg`
Now you can setup nginx to listen on the upstream of bitly.
Here’s a very simple config for Nginx that will set up a proxy pass to Amazon ElasticSearch going through the bit.ly oauth2_proxy:
That’s it.
Hope this helps.