11 Configuration
dejafu edited this page 2024-06-19 11:14:24 +02:00

You can configure the app using environment variables. These are defined in netbox.env, postgres.env, redis.env, and redis-cache.env. Read Environment Variables in Compose to understand about the various possibilities to overwrite these variables. (The easiest solution being simply adjusting that file.)

To find all possible variables, have a look at the configuration.py and docker-entrypoint.sh files. Generally, the environment variables are called the same as their respective NetBox configuration variables. Variables which are arrays are usually composed by putting all the values into the same environment variables with the values separated by a whitespace (" "). For example defining ALLOWED_HOSTS=localhost ::1 127.0.0.1 would allows access to NetBox through http://localhost:8080, http://[::1]:8080 and http://127.0.0.1:8080.

Configure for Production

The default settings are optimized for (local) development environments. You should therefore adjust the following settings in your configuration for production setup

Secrets

Please change the following settings to keep your setup safe.

  • SUPERUSER_PASSWORD, see also the next section.
  • SUPERUSER_API_TOKEN, see also the next section.
  • DB_PASSWORD and POSTGRES_PASSWORD
  • SECRET_KEY
  • EMAIL_PASSWORD, see also the next section.
  • NAPALM_PASSWORD
  • REDIS_PASSWORD
  • REDIS_CACHE_PASSWORD
  • AUTH_LDAP_BIND_PASSWORD

Generate Secret Key

docker compose run netbox python3 /opt/netbox/netbox/generate_secret_key.py

Operations

These settings are also relevant:

  • ALLOWED_HOSTS: Add all URLs that lead to your Netbox instance, space separated. E.g. ALLOWED_HOSTS=netbox.mycorp.com server042.mycorp.com 2a02:123::42 10.0.0.42 localhost ::1 127.0.0.1 (It's good advice to always allow localhost connections for easy debugging, i.e. localhost ::1 127.0.0.1.)
  • DB_*: Use your own persistent database. Don't use the default passwords!
  • EMAIL_*: Use your own mailserver.
  • MAX_PAGE_SIZE: Use the recommended default of 1000.
  • SUPERUSER_*: Only define those variables during the initial setup, and drop them once the DB is set up. Don't use the default passwords!
  • SKIP_SUPERUSER: Set to any value after you've created the superuser.
  • REDIS_*: Use your own persistent redis. Don't use the default passwords!

Custom Configuration Files

You can create you own configuration files if you need to configure something that can't be configured via the environment variables. See the configuration/extra.py file as an example. This works for regular configuration as well as for ldap configuration files, with the little (obvious?) difference that ldap configuration files are placed in configuration/ldap/.

The files are read in the order in which they are received from the system, which usually is alphabetical order. Later files take precedence over previous files. All custom files take precedence over the default configuration files configuration.py and ldap_config.py.