We'll set up a simple WSGI front end using gunicorn for the purposes of this guide. For web servers, we provide example configurations for both nginx and Apache. (You are of course free to use whichever combination of HTTP and WSGI services you'd like.) We'll also use supervisord to enable service persistence.


For the sake of brevity, only Ubuntu 18.04 instructions are provided here, but this sort of web server and WSGI configuration is not unique to NetBox. Please consult your distribution's documentation for assistance if needed.

Web Server Installation

Option A: nginx

The following will serve as a minimal nginx configuration. Be sure to modify your server name and installation path appropriately.

# apt-get install -y nginx

Once nginx is installed, save the following configuration to /etc/nginx/sites-available/netbox. Be sure to replace netbox.example.com with the domain name or IP address of your installation. (This should match the value configured for ALLOWED_HOSTS in configuration.py.)

server {
    listen 80;

    server_name netbox.example.com;

    client_max_body_size 25m;

    location /static/ {
        alias /opt/netbox/netbox/static/;

    location / {
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;

Then, delete /etc/nginx/sites-enabled/default and create a symlink in the sites-enabled directory to the configuration file you just created.

# cd /etc/nginx/sites-enabled/
# rm default
# ln -s /etc/nginx/sites-available/netbox

Restart the nginx service to use the new configuration.

# service nginx restart

To enable SSL, consider this guide on securing nginx with Let's Encrypt.

Option B: Apache

# apt-get install -y apache2 libapache2-mod-wsgi-py3

Once Apache is installed, proceed with the following configuration (Be sure to modify the ServerName appropriately):

<VirtualHost *:80>
    ProxyPreserveHost On

    ServerName netbox.example.com

    Alias /static /opt/netbox/netbox/static

    # Needed to allow token-based API authentication
    WSGIPassAuthorization on

    <Directory /opt/netbox/netbox/static>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Require all granted

    <Location /static>
        ProxyPass !

    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
    ProxyPass /
    ProxyPassReverse /

Save the contents of the above example in /etc/apache2/sites-available/netbox.conf, enable the proxy and proxy_http modules, and reload Apache:

# a2enmod proxy
# a2enmod proxy_http
# a2enmod headers
# a2ensite netbox
# service apache2 restart

To enable SSL, consider this guide on securing Apache with Let's Encrypt.

gunicorn Installation

Install gunicorn:

# pip3 install gunicorn

Save the following configuration in the root netbox installation path as gunicorn_config.py (e.g. /opt/netbox/gunicorn_config.py per our example installation). Be sure to verify the location of the gunicorn executable on your server (e.g. which gunicorn) and to update the pythonpath variable if needed. If using CentOS/RHEL, change the username from www-data to nginx or apache. More info on max_requests can be found in the gunicorn docs.

command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = ''
workers = 3
user = 'www-data'
max_requests = 5000
max_requests_jitter = 500

supervisord Installation

Install supervisor:

# apt-get install -y supervisor

Save the following as /etc/supervisor/conf.d/netbox.conf. Update the command and directory paths as needed. If using CentOS/RHEL, change the username from www-data to nginx or apache.

command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = www-data

command = python3 /opt/netbox/netbox/manage.py rqworker
directory = /opt/netbox/netbox/
user = www-data

Then, restart the supervisor service to detect and run the gunicorn service:

# service supervisor restart

At this point, you should be able to connect to the nginx HTTP service at the server name or IP address you provided. If you are unable to connect, check that the nginx service is running and properly configured. If you receive a 502 (bad gateway) error, this indicates that gunicorn is misconfigured or not running.


Please keep in mind that the configurations provided here are bare minimums required to get NetBox up and running. You will almost certainly want to make some changes to better suit your production environment.