# Scroll search not working after using NGINX proxy

**URL:** <https://discuss.elastic.co/t/scroll-search-not-working-after-using-nginx-proxy/67214>\
**Category:** Elasticsearch\
**Created:** [November 25, 2016, 7:26pm UTC](https://discuss.elastic.co/t/scroll-search-not-working-after-using-nginx-proxy/67214 "2016-11-25T19:26:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![whittssg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whittssg/32/27669_2.png) [@whittssg](https://discuss.elastic.co/u/whittssg)\
**Post date:** [November 25, 2016, 7:26pm UTC](https://discuss.elastic.co/t/scroll-search-not-working-after-using-nginx-proxy/67214/1 "2016-11-25T19:26:43Z")

</div>

Hello, I am trying to route my elasticsearch.js queries through nginx (so that i can set the elasticsearch network.host to 127.0.0.1).

I added this to my nginx config so that anything that hits my domain name with \_search get routed to 127.0.0.1:9200:

location ~ ^/.\*/\_search$ {  
proxy\_pass [http://127.0.0.1:9200](http://127.0.0.1:9200);  
}

My search queries have scroll enabled since some of them can return quite a lot of records. If the search only brings back a few rows then it works fine but if it has to scroll it errors.

When it scrolls i get this error:

Request URL:[https://mysite.mydomain.com/\_search/scroll?scroll=30s](https://mysite.mydomain.com/_search/scroll?scroll=30s)  
Request Method:POST  
Status Code:400 Bad Request  
Remote Address:serverIP:443

**EDIT**

When i scroll without it going through NGINX it looks like this:  
Request URL:[http://serverIP:9200/\_search/scroll?scroll=30s](http://serverIP:9200/_search/scroll?scroll=30s)  
Request Method:POST  
Status Code:200 OK  
Remote Address:serverIP:9200

The only difference i see (appart from the domain vs server ip) is that the remote address on the none nginx is 9200 where as with NGINX is 443)

I guess i am missing a setting in NGINX to make this work

**EDIT**

Anyone have any ideas why scroll will not work?

Another edit... It doesnt matter if i use 443 or not - if i isolate the \_search on any port it does the same..

It gives the following error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '[http://localhost:9000](http://localhost:9000)'

Elasticsearch config has the following:

http.cors.enabled: true  
http.cors.allow-origin: "\*"

if i add the header via nginx it gives this error:

The 'Access-Control-Allow-Origin' header contains multiple values '\*, \*', but only one is allowed

Why does it single out the scroll request but nothing else?

Thanks

---

<div class="post-metadata">

**Author:** ![whittssg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whittssg/32/27669_2.png) [@whittssg](https://discuss.elastic.co/u/whittssg)\
**Post date:** [November 29, 2016, 6:00pm UTC](https://discuss.elastic.co/t/scroll-search-not-working-after-using-nginx-proxy/67214/2 "2016-11-29T18:00:14Z")

</div>

Never mind.. the issue was with my regex only matching URLs that ended with \_search rather than contains \_search.: location ~ \_search {}

---

<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:** [December 27, 2016, 6:00pm UTC](https://discuss.elastic.co/t/scroll-search-not-working-after-using-nginx-proxy/67214/3 "2016-12-27T18:00:17Z")

</div>

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