Netbox for Production
In the previous guide, we walked through the installation of Netbox and some of the required dependencies. We ended with a working Netbox instance that successfully ran a development server.
This guide builds on what was accomplished in the previous guide with a focus of moving our Netbox instance to a production environment. Key technologies used are Gunicorn and Nginx.
By the end, we will have a Netbox instance that is accessible via a domain name and is served over HTTPS connecting back to our local Netbox instance.
Pre-requisites
Section titled “Pre-requisites”- You’ll need an Ubuntu 22.04 server. I’m using a VM running on Proxmox.
- You’ll need to check to ensure your Ubuntu install has Python3 v3.10 or higher. In my case I used a full install of Ubuntu 22.04 Server which come with v3.10 pre-installed. If you have a lesser version, go find a guide on how to upgrade Python3.
I recommend that you have worked through the previous guide on getting Netbox up and running in a local development environment. This guide will build on that work.
Steps:
Section titled “Steps:”Gunicorn
Section titled “Gunicorn”Netbox includes a default config for Gunicorn. We’ll preserve this config for updates and and instead will create a copy of the config file to make our changes.
1. Copy Gunicorn Config
Section titled “1. Copy Gunicorn Config”sudo cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py2. Setup Systemd Service
Section titled “2. Setup Systemd Service”We will want to create a systemd service to manage the Gunicorn service. This will allow us to start, stop, and restart the service as needed and to run the service in the background.
sudo cp -v /opt/netbox/contrib/*.service /etc/systemd/system/sudo systemctl daemon-reloadNext, we will start netbox and netbox-rq services:
sudo systemctl enable --now netbox netbox-rq