# How to set multi value about http.cors.allow-origin in es 5.x

**URL:** <https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 3:07am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146 "2017-08-24T03:07:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 24, 2017, 3:07am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/1 "2017-08-24T03:07:43Z")

</div>

how to set http.cors.allow-origin in es  
when i wan't to only **two ip** can use elasticsearch-head connect to es?  
how can set teh **http.cors.allow-origin**  
this is one ip **http.cors.allow-origin: /https?://localhost(:[0-9]+)?/**  
**how about two ip settings?**

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 24, 2017, 6:47am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/2 "2017-08-24T06:47:03Z")

</div>

some on can help me ?  
thanks..

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 24, 2017, 12:50pm UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/3 "2017-08-24T12:50:05Z")

</div>

can solve it  
@elastic

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 25, 2017, 2:52am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/4 "2017-08-25T02:52:17Z")

</div>

thanks..

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2017, 7:56am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/5 "2017-08-25T07:56:23Z")

</div>

Please see the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html#_settings_2) - if you prepend and append a `/` then the value is treated as a regular expression. You need to create a regular expression that matches your two hosts.

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 25, 2017, 9:05am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/6 "2017-08-25T09:05:27Z")

</div>

yes.i know, but i don't know how to create a regular expression that matches two hosts.  
can give me a example  
thanks..  
@spinscale

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 25, 2017, 9:17am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/7 "2017-08-25T09:17:30Z")

</div>

> [@zqc0512](#):
>
> http.cors.allow-origin: /https?://localhost(:[0-9]+)?/

**is linke this http.cors.allow-origin: /https?://localhost(:[0-9]+)?/http?://xxx.xxx.xxx.xxx(:[0-9]+)?**

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2017, 4:06pm UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/8 "2017-08-25T16:06:23Z")

</div>

try something like `https?:\/\/(localhost|otherhost.org)(:[0-9]+)?` (fully untested, you should go with some regex tester first and then see if the regex is doing what you expect)

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 30, 2017, 7:59am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/9 "2017-08-30T07:59:38Z")

</div>

thanks.  
this slove it.

---

<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:** [September 27, 2017, 7:59am UTC](https://discuss.elastic.co/t/how-to-set-multi-value-about-http-cors-allow-origin-in-es-5-x/98146/10 "2017-09-27T07:59:41Z")

</div>

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