# Enable anonymous access via api/env variables in elasticsearch with xpack enabled

**URL:** <https://discuss.elastic.co/t/enable-anonymous-access-via-api-env-variables-in-elasticsearch-with-xpack-enabled/248490>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security, docker\
**Created:** [September 14, 2020, 8:35am UTC](https://discuss.elastic.co/t/enable-anonymous-access-via-api-env-variables-in-elasticsearch-with-xpack-enabled/248490 "2020-09-14T08:35:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrraj470](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrraj470/32/75054_2.png) [@mrraj470](https://discuss.elastic.co/u/mrraj470)\
**Post date:** [September 14, 2020, 8:35am UTC](https://discuss.elastic.co/t/enable-anonymous-access-via-api-env-variables-in-elasticsearch-with-xpack-enabled/248490/1 "2020-09-14T08:35:29Z")

</div>

I want to setup my elasticsearch in such a way that it is readable by everyone (without authentication header) but write access needs authentication. Of course, I can use anonymous user, but I don't find any article showing how to setup this anonymous access with rest api/env variables (except .yml configs).

Is there any other way?

---

<div class="post-metadata">

**Author:** ![mrraj470](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mrraj470/32/75054_2.png) [@mrraj470](https://discuss.elastic.co/u/mrraj470)\
**Post date:** [September 23, 2020, 9:38am UTC](https://discuss.elastic.co/t/enable-anonymous-access-via-api-env-variables-in-elasticsearch-with-xpack-enabled/248490/2 "2020-09-23T09:38:10Z")

</div>

I just got to know, we can define anonymous user via env variables like below.

```
xpack.security.authc.anonymous.roles = 'some_role'
xpack.security.authc.anonymous.authz_exception = 'true'

```

I was not really aware of any elasticsearch.yaml/kibana.yaml configurations can be defined in env variable.

But it would be cool, if we can define new role and it's privileges here itself for assigning it to anonymous user.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 21, 2020, 9:38am UTC](https://discuss.elastic.co/t/enable-anonymous-access-via-api-env-variables-in-elasticsearch-with-xpack-enabled/248490/3 "2020-10-21T09:38:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
