Skip to main content

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

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

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

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'])