私はElasticsearchを使用してログを保存し、クエリを実行しています。私は、AngularJsを使用してElasticsearchからWebページに照会された情報を表示するフロントエンドUIを作成しています。Elasticsearch CORS HTTPDとAngularJs通信の問題
XMLHttpRequest cannot load http://my_ip/ali_viewer/log/_search. Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
これはstackoverflowの上で見られる共通の問題のようです:Webページには、私は次のエラーを取得していますAngularJsを使用してElasticsearchを照会する場合Elasticsearchがポート9200で実行されているポート80上のCentOS 6のApache HTTPD上で実行されています残りのウェブサイトでは成功していないので、私は自分の具体的な構成を投稿します。
の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
は誰もが知っていますか?