I am using Elasticsearch to store and query logs. I am creating a front end UI that will display the queried information from Elasticsearch to a webpage using AngularJs. The webpage is ruing on CentOS 6 Apache HTTPD on port 80. Elasticsearch is ruing on port 9200. When I query Elasticsearch using AngularJs I am getting the following error:
XMLHttpRequest caot load http://my_ip/ali_viewer/log/_search. Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
This seems to be a common issue found on stackoverflow and the rest of the web, but after trying so many solutions with no success I will post my specific configuration.
httpd.conf
<Directory />
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type"
Options FollowSymLinks
AllowOverride None
</Directory>
elasticsearch.yml
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
Does anyone know why this isn't working?
