# NetBox CSRF Settings

### Introduction

This playbook `netbox-csrf` will add your domains in the following format to the NetBox `settings.py` file based on the `DOMAIN` variable in Semaphore.

- `http://*.yourdomain.com`
- `https://*.yourdomain.com`
- `http://yourdomain.com`
- `https://yourdomain.com`

When you run the playbook, it will look like this:

[![image.png](https://docs.netos.io/uploads/images/gallery/2024-09/scaled-1680-/FIFPzvJXKrPhjm3J-image.png)](https://docs.netos.io/uploads/images/gallery/2024-09/FIFPzvJXKrPhjm3J-image.png)

### Use Case

If your server name is `uk-lab-nb01.core.netos.io`, and you configured a DNS CNAME to give it a more friendly name like `demo2.netos.io` via a reverse proxy, then you would see this error and won't be able to login:

[![image.png](https://docs.netos.io/uploads/images/gallery/2024-09/scaled-1680-/Gek6Giygy04COwqM-image.png)](https://docs.netos.io/uploads/images/gallery/2024-09/Gek6Giygy04COwqM-image.png)

To fix this, change the domain to in the NetBox Global Settings:

[![image.png](https://docs.netos.io/uploads/images/gallery/2024-09/scaled-1680-/ExXDkAV0PMPqSzYi-image.png)](https://docs.netos.io/uploads/images/gallery/2024-09/ExXDkAV0PMPqSzYi-image.png)

Which will create a `settings.py` file entry like this and fix the error:

`CSRF_TRUSTED_ORIGINS = getattr(configuration, 'CSRF_TRUSTED_ORIGINS', ['http://netos.io', 'https://netos.io', 'http://*.netos.io', 'https://*.netos.io'])`