Skip to content

Hide Elasticsearch behind Apache HTTP server

José Villaveces edited this page Nov 11, 2015 · 1 revision

Requirements

  1. Elasticsearch instance up and running.
  2. Apache HTTP server. If you haven't install it already, you can get Apache installed on your server through apt-get:

sudo apt-get update

sudo apt-get install apache2

Setup mod_proxy

Install and enable mod_proxy so Apache can forward requests to any ports you want:

apt-get install libapache2-mod-proxy-html
a2enmod proxy
a2enmod proxy_http

Either create or edit a vhost for elasticsearch.

In this case we are going to edit Apache's default vhost 000-default.conf.

  1. Open the file 000-default.conf vi /etc/apache2/sites-available/default-000.conf
  2. Add a new location. You can copy an paste the code bellow, just replace %your_location% with the location you want to use.
#ProxyPass http://localhost:9200/
<Location /%your_location%>
     ProxyPass http://localhost:9200/
     ProxyPassReverse http://localhost:9200/
</Location>
  1. Save and close the file. If necessary restart Apache.
  2. In your browser try to access elastic search by navigating to %your_location%.
http://localhost/%your_location%