# How to set up elasticsearch to run on the web?

**URL:** <https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904>\
**Category:** Elasticsearch\
**Created:** [March 19, 2016, 4:28pm UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904 "2016-03-19T16:28:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhwhite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jhwhite/32/8560_2.png) [@jhwhite](https://discuss.elastic.co/u/jhwhite)\
**Post date:** [March 19, 2016, 4:28pm UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/1 "2016-03-19T16:28:35Z")

</div>

I wrote a search app locally and everything is running fine. It's just an angular front end hitting the elasticsearch.

I installed elasticsearch on my digitalocean droplet running Ubuntu 14.04 apache. I have a domain for my app and I've already got one domain there. So I'm running multiple Virtual Hosts.

My service for my angular app is set to hit the elasticsearch cluster at: host: '[http://cvilleclinicaltrials.com:9200](http://cvilleclinicaltrials.com:9200)'

But my console says ERR\_CONNECTION\_REFUSED. I'm assuming that's because my .yml file is still set to accept localhost requests only. I changed that to accept from _eth0_ (which I'm fairly certain is a bad idea but I wanted to get this working) and then I get an error about CORS.

So at the end of the .yml file I added:

http.cors.enabled: true  
http.cors.allow-origin: "\*"  
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE  
http.cors.allow-headers: "X-Requested-With,X-Auth-Token,Content-Type, Content-Length"

But then when I restart elasticsearch service my log file shows the node stopping, stopped, closing, closed but it never restarts. If I comment out the above lines or remove them and restart the service it starts up fine.

So my question is, what is the correct way to set this up so my angular app will hit elasticsearch running on my domain on digitalocean?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 19, 2016, 4:58pm UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/2 "2016-03-19T16:58:43Z")

</div>

Do not expose ES to the web without some kind of filter or proxy that can restrict what clients are allowed to do.

---

<div class="post-metadata">

**Author:** ![jhwhite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jhwhite/32/8560_2.png) [@jhwhite](https://discuss.elastic.co/u/jhwhite)\
**Post date:** [March 19, 2016, 5:04pm UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/3 "2016-03-19T17:04:12Z")

</div>

Yes, that would be ideal.

I'm not a sys admin guy. Is there some guide somewhere on how to do all of this? How do I setup elasticsearch for a web app?

How do I set it up using Apache or nginx?

How do I setup the filter or proxy?

Is there some trick to editing the .yml file? The one locally works but not on my server.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 19, 2016, 7:16pm UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/4 "2016-03-19T19:16:19Z")

</div>

> I'm not a sys admin guy. Is there some guide somewhere on how to do all of this? How do I setup elasticsearch for a web app?

ES has no "safe web app mode". You need to run a custom proxy to filter the requests.

> How do I set it up using Apache or nginx?

You can read up on the REST API and use the proxy to only allow exactly the kind of requests that should be allowed, i.e. what's absolutely necessary for your web app to function.

Alternatively, write your own custom back end that has full access to ES and exposes a custom API that suits your web app.

> Is there some trick to editing the .yml file? The one locally works but not on my server.

No, a YAML file is just a plain text file.

---

<div class="post-metadata">

**Author:** ![jhwhite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jhwhite/32/8560_2.png) [@jhwhite](https://discuss.elastic.co/u/jhwhite)\
**Post date:** [March 22, 2016, 2:21am UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/5 "2016-03-22T02:21:37Z")

</div>

How do I run a custom proxy? I'm not sure what that means. Do I want to have elasticsearch only allow localhost requests and forward requests sent to port :9200 through to elasticsearch using apache?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 22, 2016, 6:41am UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/6 "2016-03-22T06:41:56Z")

</div>

Yes, that'd work. Apache's access control language isn't exactly a joy to work with, but you can probably set it up to only allow access that what the webapp really needs.

---

<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:** [July 5, 2017, 11:06pm UTC](https://discuss.elastic.co/t/how-to-set-up-elasticsearch-to-run-on-the-web/44904/7 "2017-07-05T23:06:25Z")

</div>


