ElasticSearch Clustering authentication with Nginx

I have an ElasticSearch cluster with a master node on server and 5 data nodes on some other servers. I have set up a nginx reverse proxy server on server for basic authentication. My cluster data nodes can't discover master node. How can I resolve this problem? Is it necessary to install nginx on data nodes?

My ngnix configuration is as follow:
events { worker_connections 1024; } http { upstream elasticsearch { server; } server { listen 9200; auth_basic "Protected Elasticsearch"; auth_basic_user_file passwords; location / { proxy_pass http://elasticsearch; proxy_redirect off; } } }

My master node configudarion is as follow:
node.master: true node.data: false network.host: http.port: 9200

My data node configuration is as follow:
node.master: false node.data: true network.host: http.port: 9200 discovery.zen.ping.unicast.hosts: [""] // master node ip

That's why, your master will never listen on anything other than the loopback address.

my master node just response to requests from proxy server.
upstream elasticsearch {
proxy server receives every request on port 9200 and after authentication send it to elasticSearch.
nginx (proxy server) and master node is installed on same server,