Nginx proxy issues

(Warner Onstine) #1

We setup our ES server on EC2 using the chef setup described here:

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,
} else {
if (reqParams.method === 'POST' || reqParams.method === 'PUT' ||
reqParams.method === 'DELETE') {
//olderversions of nginx really want this.
request.setHeader('Content-Length', 0);

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',
port: 8443,
log: 'trace'

Anyone else run into this? Easy fix? Maybe? :slight_smile:

Thanks in advance!


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
To view this discussion on the web visit
For more options, visit

(system) #2