mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
More configuration cleanup
This commit is contained in:
@ -6,6 +6,18 @@ NetBox's local configuration is held in `netbox/netbox/configuration.py`. An exa
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
#### ALLOWED_HOSTS
|
||||||
|
|
||||||
|
This is a list of valid host names by which NetBox may be reached. This list is used to defend against cross-site scripting (XSS) attacks. You must specify at least one host name.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
#### DATABASE
|
#### DATABASE
|
||||||
|
|
||||||
NetBox requires access to a PostgreSQL database service to store data. This service can run locally or on a remote system. The following parameters must be defined within the `DATABASE` dictionary:
|
NetBox requires access to a PostgreSQL database service to store data. This service can run locally or on a remote system. The following parameters must be defined within the `DATABASE` dictionary:
|
||||||
@ -26,6 +38,7 @@ Please note that this key is **not** used for hashing user passwords or for the
|
|||||||
|
|
||||||
`SECRET_KEY` should be at least 50 characters in length and contain a random mix of letters, digits, and symbols. The following Python code can be used to generate a key:
|
`SECRET_KEY` should be at least 50 characters in length and contain a random mix of letters, digits, and symbols. The following Python code can be used to generate a key:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
@ -35,27 +48,41 @@ random.seed = (os.urandom(2048))
|
|||||||
print ''.join(random.choice(charset) for c in range(50))
|
print ''.join(random.choice(charset) for c in range(50))
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### ALLOWED_HOSTS
|
|
||||||
|
|
||||||
This is a list of valid host names by which NetBox may be reached. This list is used to defend against cross-site scripting (XSS) attacks. You must specify at least one host name.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```
|
|
||||||
ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
|
|
||||||
```
|
|
||||||
|
|
||||||
## Optional Settings
|
## Optional Settings
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### TIME_ZONE
|
#### ADMINS
|
||||||
|
|
||||||
Default: UTC
|
NetBox will email details about critical errors to the administrators listed here. This should be a list of (name, email) tuples. For example:
|
||||||
|
|
||||||
The time zone NetBox will use when dealing with dates and times. It is recommended to use UTC time unless you have a specific need to use a local time zone. [List of available time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
```
|
||||||
|
ADMINS = [
|
||||||
|
['Hank Hill', 'hhill@example.com'],
|
||||||
|
['Dale Gribble', 'dgribble@example.com'],
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### DEBUG
|
||||||
|
|
||||||
|
Default: False
|
||||||
|
|
||||||
|
This setting enables debugging. This should be done only during development or troubleshooting. Never enable debugging on a production system, as it can expose sensitive data to unauthenticated users.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### EMAIL
|
||||||
|
|
||||||
|
In order to send email, NetBox needs an email server configured. The following items can be defined within the `EMAIL` setting:
|
||||||
|
|
||||||
|
* SERVER - Host name or IP address of the email server (use `localhost` if running locally)
|
||||||
|
* PORT - TCP port to use for the connection (default: 25)
|
||||||
|
* USERNAME - Username with which to authenticate
|
||||||
|
* PASSSWORD - Password with which to authenticate
|
||||||
|
* TIMEOUT - Amount of time to wait for a connection (seconds)
|
||||||
|
* FROM_EMAIL - Sender address for emails sent by NetBox
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -67,11 +94,11 @@ Setting this to True will permit only authenticated users to access any part of
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### PAGINATE_COUNT
|
#### MAINTENANCE_MODE
|
||||||
|
|
||||||
Default: 50
|
Default: False
|
||||||
|
|
||||||
Determine how many objects to display per page within each list of objects.
|
Setting this to True will display a "maintenance mode" banner at the top of every page.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -83,16 +110,16 @@ If provided, NetBox will use these credentials to authenticate against devices w
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### MAINTENANCE_MODE
|
#### PAGINATE_COUNT
|
||||||
|
|
||||||
Default: False
|
Default: 50
|
||||||
|
|
||||||
Setting this to True will display a "maintenance mode" banner at the top of every page.
|
Determine how many objects to display per page within each list of objects.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### DEBUG
|
#### TIME_ZONE
|
||||||
|
|
||||||
Default: False
|
Default: UTC
|
||||||
|
|
||||||
This setting enables debugging. This should be done only during development or troubleshooting. Never enable debugging on a production system, as it can expose sensitive data to unauthenticated users.
|
The time zone NetBox will use when dealing with dates and times. It is recommended to use UTC time unless you have a specific need to use a local time zone. [List of available time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
||||||
|
@ -30,13 +30,21 @@ SECRET_KEY = ''
|
|||||||
# #
|
# #
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
|
# Specify one or more name and email email address tuples representing NetBox administrators. These people will be
|
||||||
|
# notified of application errors (assuming correct email settings are provided).
|
||||||
|
ADMINS = [
|
||||||
|
# ['John Doe', 'jdoe@example.com'],
|
||||||
|
]
|
||||||
|
|
||||||
# Email settings
|
# Email settings
|
||||||
EMAIL = {
|
EMAIL = {
|
||||||
'SERVER': 'localhost',
|
'SERVER': 'localhost',
|
||||||
|
'PORT': 25,
|
||||||
'USERNAME': '',
|
'USERNAME': '',
|
||||||
'PASSWORD': '',
|
'PASSWORD': '',
|
||||||
|
'TIMEOUT': 10, # seconds
|
||||||
|
'FROM_EMAIL': '',
|
||||||
}
|
}
|
||||||
SERVER_EMAIL = 'netbox@digitalocean.com'
|
|
||||||
|
|
||||||
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
|
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
|
||||||
# are permitted to access most data in NetBox (excluding secrets) but not make any changes.
|
# are permitted to access most data in NetBox (excluding secrets) but not make any changes.
|
||||||
|
@ -12,7 +12,7 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
# Import local configuration
|
# Import local configuration
|
||||||
for setting in ['ALLOWED_HOSTS', 'DATABASE', 'SECRET_KEY', 'STATIC_ROOT']:
|
for setting in ['ALLOWED_HOSTS', 'DATABASE', 'SECRET_KEY']:
|
||||||
try:
|
try:
|
||||||
globals()[setting] = getattr(configuration, setting)
|
globals()[setting] = getattr(configuration, setting)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -20,9 +20,10 @@ for setting in ['ALLOWED_HOSTS', 'DATABASE', 'SECRET_KEY', 'STATIC_ROOT']:
|
|||||||
"documentation.".format(setting))
|
"documentation.".format(setting))
|
||||||
|
|
||||||
# Default configurations
|
# Default configurations
|
||||||
ADMINS = getattr(configuration, 'ADMINS', False)
|
ADMINS = getattr(configuration, 'ADMINS', [])
|
||||||
CSRF_TRUSTED_ORIGINS = getattr(configuration, 'CSRF_TRUSTED_ORIGINS', False)
|
CSRF_TRUSTED_ORIGINS = getattr(configuration, 'CSRF_TRUSTED_ORIGINS', [])
|
||||||
DEBUG = getattr(configuration, 'DEBUG', False)
|
DEBUG = getattr(configuration, 'DEBUG', False)
|
||||||
|
EMAIL = getattr(configuration, 'EMAIL', {})
|
||||||
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
||||||
MAINTENANCE_MODE = getattr(configuration, 'MAINTENANCE_MODE', False)
|
MAINTENANCE_MODE = getattr(configuration, 'MAINTENANCE_MODE', False)
|
||||||
PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
|
PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
|
||||||
@ -39,6 +40,15 @@ DATABASES = {
|
|||||||
'default': configuration.DATABASE,
|
'default': configuration.DATABASE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Email
|
||||||
|
EMAIL_HOST = EMAIL.get('SERVER')
|
||||||
|
EMAIL_PORT = EMAIL.get('PORT', 25)
|
||||||
|
EMAIL_HOST_USER = EMAIL.get('USER')
|
||||||
|
EMAIL_HOST_PASSWORD = EMAIL.get('PASSWORD')
|
||||||
|
EMAIL_TIMEOUT = EMAIL.get('TIMEOUT', 10)
|
||||||
|
SERVER_EMAIL = EMAIL.get('FROM_EMAIL')
|
||||||
|
EMAIL_SUBJECT_PREFIX = '[NetBox] '
|
||||||
|
|
||||||
# Installed applications
|
# Installed applications
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
@ -97,6 +107,7 @@ TEMPLATES = [
|
|||||||
# WSGI
|
# WSGI
|
||||||
WSGI_APPLICATION = 'netbox.wsgi.application'
|
WSGI_APPLICATION = 'netbox.wsgi.application'
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
USE_X_FORWARDED_HOST = True
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
||||||
@ -106,6 +117,7 @@ USE_TZ = True
|
|||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
# https://docs.djangoproject.com/en/1.8/howto/static-files/
|
||||||
|
STATIC_ROOT = BASE_DIR + '/static/'
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
STATICFILES_DIRS = (
|
STATICFILES_DIRS = (
|
||||||
os.path.join(BASE_DIR, "project-static"),
|
os.path.join(BASE_DIR, "project-static"),
|
||||||
|
Reference in New Issue
Block a user