# Nginx proxy issues

**URL:** <https://discuss.elastic.co/t/nginx-proxy-issues/15709>\
**Category:** Elasticsearch\
**Created:** [February 10, 2014, 11:04pm UTC](https://discuss.elastic.co/t/nginx-proxy-issues/15709 "2014-02-10T23:04:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warner\_Onstine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warner_onstine/32/1086_2.png) [@Warner\_Onstine](https://discuss.elastic.co/u/Warner_Onstine)\
**Post date:** [February 10, 2014, 11:04pm UTC](https://discuss.elastic.co/t/nginx-proxy-issues/15709/1 "2014-02-10T23:04:06Z")

</div>

We setup our ES server on EC2 using the chef setup described here:  
[http://www.elasticsearch.org/tutorials/deploying-elasticsearch-with-chef-solo/](http://www.elasticsearch.org/tutorials/deploying-elasticsearch-with-chef-solo/)

We setup auth to it and then tried to use the elasticsearch-js client to  
connect to it and thus began our problems.

At first it wasn't clear what was going on but after some digging  
determined that the client wasn't sending 'Content-Length' of 0 when  
posting, deleting, etc. to this version of nginx (1.1.19). Apparently this  
is only required on older versions of nginx.

I patched the http.js file so that it would send the content-length of 0 to  
get around this problem (around line 168):  
if (params.body) {  
request.setHeader('Content-Length', Buffer.byteLength(params.body,  
'utf8'));  
request.end(params.body);  
} else {  
if (reqParams.method === 'POST' || reqParams.method === 'PUT' ||  
reqParams.method === 'DELETE') {  
//olderversions of nginx really want this.  
request.setHeader('Content-Length', 0);  
}  
request.end();  
}

Then our second issue started as we had just configured this server up with  
ssl to secure the basic auth we were using (as described in the chef doc  
above) and we started getting this message from nginx:  
The plain HTTP request was sent to HTTPS port

If I switch everything back to 8080 and plain http it works. I have a  
different ES client that I can use successfully to connect to the server  
over https so I know that isn't the issue. From what I can tell in the code  
it should be sending it to the proper port unless I'm missing some config  
option somewhere.

Here's my host info:  
var client = new elasticsearch.Client({  
hosts: [{  
protocol: 'https',  
host:'[myserver.com](http://myserver.com)',  
port: 8443,  
auth:'user:password'  
}],  
log: 'trace'  
});

Anyone else run into this? Easy fix? Maybe? 🙂

Thanks in advance!

-warner

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAJNTuMDEGjUGNv%2BgRNJW-Y5dkMYBTzQ89hrGp2HK6sA\_S7bbuQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJNTuMDEGjUGNv%2BgRNJW-Y5dkMYBTzQ89hrGp2HK6sA_S7bbuQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:51am UTC](https://discuss.elastic.co/t/nginx-proxy-issues/15709/2 "2017-07-06T01:51:19Z")

</div>


