Many of these steps come from this wonderful blog post here.
- Follow steps one through six here for installing Nginx.
- Install Java, either OpenJDK (#1) or Oracle Java (#2)
-
apt-get install openjdk-6-jre
-
sudo add-apt-repository ppa:webupd8team/java apt-get update sudo apt-get install oracle-java7-installer
-
- Test that Java is installed:
java -version
- Download the deb file for Elasticsearch (below is 1.3.2, make sure you get the most recent one from the official location)
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.2.deb
- Install the deb file
dpkg -i elasticsearch-1.3.2.deb
- Set Elasticsearch to start on boot
sudo update-rc.d elasticsearch defaults 95 10
- Start Elasticsearch
sudo service elasticsearch start
- Test to see if it is running. NOTE: Elasticsearch sometimes takes a couple of seconds to spin up. If you get a message saying
Failed to connect to localhost port 9200: Connection refused
wait a couple of seconds and try again.curl localhost:9200
- Secure Elasticsearch to only allow local connections
sudo vi /etc/elasticsearch/elasticsearch.yml
- Comment out (if they aren’t already) these two lines:
#network.bind_host: #some_value #network.publish_host: #some_other_value
-
Uncomment and set this line:
network.host: localhost
- Comment out (if they aren’t already) these two lines:
- Restart elasticsearch
sudo service elasticsearch restart
- For Nginx we’re just going to modify the default site
sudo vi /etc/nginx/sites-enabled/default
- Replace everything with the below, changing example.com with your domain
server { listen 80; server_name example.com; location / { rewrite ^/(.*) /$1 break; proxy_ignore_client_abort on; proxy_pass http://localhost:9200; proxy_redirect http://localhost:9200 http://example.com/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } }