I am attempting to proxy Elasticsearch through nginx. Most things seem to work, but one thing that is having problems is creating indexes.
This works when connecting directly to ES:
curl -XPUT http://localhost:9200/foo" -fsS -o/dev/null -d@- << BODY
{
"settings": {
"analysis": {
"analyzer": {
"case_insensitive_sort": {
"tokenizer": "keyword",
"filter": ["lowercase"]
}
}
},
"index": {
"number_of_replicas": 0
}
}
}
BODY
But when I try to put nginx up as a proxy in front of ES, I get a 404 from ES. My nginx config is:
upstream es {
server 127.0.0.2:9200;
}
map $request_method $upstream {
default es;
}
server {
listen 127.0.0.1:9200;
client_max_body_size 20M;
location / {
proxy_pass http://$upstream;
}
}
ES is setup to listen on an IP address, so I don't think this is related to host headers not being passed:
# elasticsearch.yml
network.bind_host: 127.0.0.2
This feels like something finicky about ES, but maybe I'm doing something dumb and wrong with the nginx proxy. I'm not really sure what else to try. I've seen some related issues where the solution was to not use nginx, but that's not really an option for me.
nginx 1.14, elasticsearch 1.7.