# Need help to change CORS policy in AWX 20.0.1

**URL:** <https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436>\
**Category:** AWX Project\
**Tags:** awx, ee, kubernetes\
**Created:** [March 14, 2022, 7:47pm UTC](https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436 "2022-03-14T19:47:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Rivera](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Alex\_Rivera](https://forum.ansible.com/u/Alex_Rivera)\
**Post date:** [March 14, 2022, 7:47pm UTC](https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436/1 "2022-03-14T19:47:49Z")

</div>

Hello everyone,

I just noticed a service that invokes the AWX API from another website is not working because of AWX’s CORS policies.

Back there in version 15x I was using Docker and just updated this file under /etc/tower in the awx-web container:

**settings.py**

and added these lines:

**MIDDLEWARE = [‘corsheaders.middleware.CorsMiddleware’] + MIDDLEWARE**  
**CORS\_ORIGIN\_ALLOW\_ALL = True**

Reboot the containers and that’s it

But now with the Kubernetes deployment I have no idea how to customize this awx-web container, it just pulls it from [quay.io](http://quay.io) as I can see in the configuration.

I’m using a custom Execution Environment that I’ve built with the ansible-builder, but idk if there’s a similar tool for web container.

Do I need to modify the [https://quay.io/repository/ansible/awx](https://quay.io/repository/ansible/awx) image? And if so, how do I make the operator use my own image?

I’m guessing through the **awx.yml**?

Something like this? has anyone tried this?

**web\_images:**  
**- image: [quay.io/](http://quay.io/)/custom-awx-image:tag**

Any help is appreciated.  
Thanks in advance!

Regards  
Alex

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [March 15, 2022, 12:50pm UTC](https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436/2 "2022-03-15T12:50:14Z")

</div>

Hi Alex,

For customizing settings.py, did you try [https://github.com/ansible/awx-operator#extra-settings](https://github.com/ansible/awx-operator#extra-settings)?

Concerning overriding the image used, I am not sure this is how to do it, esp. w.r.t the fact that the variable is underscore-prefixed, hence meaning an internal scope: [https://github.com/ansible/awx-operator/blob/devel/roles/installer/defaults/main.yml#L127](https://github.com/ansible/awx-operator/blob/devel/roles/installer/defaults/main.yml#L127)

Let us know how it goes,

Vincent

---

<div class="post-metadata">

**Author:** ![Alex\_Rivera](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Alex\_Rivera](https://forum.ansible.com/u/Alex_Rivera)\
**Post date:** [March 16, 2022, 1:03am UTC](https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436/3 "2022-03-16T01:03:39Z")

</div>

Hi Vincent,

Thanks! that worked just for what I needed! I ended up modifying the AWX image but that’s no longer needed and it wasn’t working anyways because **AWX ConfigMaps** wasn’t getting updated and /etc/tower/settings.py had the default values.

With what you mentioned it added the values I needed for the CORS policy.

Before I was getting this error:

**_“https://url:port has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requestes resource.”_**

I just changed the **spec** in my awx.yaml

spec:  
extra\_settings:

- setting: MIDDLEWARE  
value: “[‘corsheaders.middleware.CorsMiddleware’] + MIDDLEWARE”
- setting: CORS\_ORIGIN\_ALLOW\_ALL  
value: “True”

kubectl deploy -f awx.yaml

and AWX ConfigMaps was updated in Kubernetes, I noticed the containers didn’t update its settings.py even when the ConfigMaps was OK, I had to downscale deployment to 0 and back to 3 in my case so the changes were sent to the AWX containers.

Sent the REST API call again and now is working as intended.

Thank you!

Regards  
Alex

---

<div class="post-metadata">

**Author:** ![Alex\_Rivera](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Alex\_Rivera](https://forum.ansible.com/u/Alex_Rivera)\
**Post date:** [March 16, 2022, 1:05am UTC](https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436/4 "2022-03-16T01:05:21Z")

</div>

Typo: the correct **kubectl** command used was:

_kubectl apply -f awx.yaml_

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [March 16, 2022, 10:26am UTC](https://forum.ansible.com/t/need-help-to-change-cors-policy-in-awx-20-0-1/36436/5 "2022-03-16T10:26:17Z")

</div>

Hi Alex,

Thanks for reporting back and taking the time to explain what you did, this will be useful to others as well!
