1

I'm trying to enable CORS on elasticsearch so I can access it from an angular app.

I'm adding

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

To the bottom of the elasticsearch.yml file. Then I restart the elasticsearch service but in my log file it shows the node stopping, stopped, closing, closed but it never restarts.

If I go into my elasticsearch.yml and remove or comment out the lines above and then restart elasticsearch.yml elasticsearch will restart fine.

So I'm not sure what I'm doing wrong.

Those lines were copied from my local install of elasticsearch but that's running on OSX. I'm not sure if there's some slight difference when the OS is Ubuntu 14.04.

This is what my .yml file looks like now based on what I found here elasticsearch.js client connection refused: Access-Control-Allow-Origin not recognized?:

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, Authorization"
Community
  • 1
  • 1
James White
  • 535
  • 10
  • 24
  • Can you try to remove the space between the property name and the colon? And you need to wrap the methods and headers within double quotes as well. – Val Mar 19 '16 at 04:33
  • I've done both those and restarted and I got the same thing. Elasticsearch stayed in a closed state. When I commented out the lines then ES restarted and is running. – James White Mar 19 '16 at 12:23

1 Answers1

1

This was my first time working with .yml files and I didn't realize that all the lines in a YAML file are required to be indented the same.

Once I matched up indentations everything was fine.

James White
  • 535
  • 10
  • 24