Target: single-node NetBox install behind Nginx, PostgreSQL, Redis, and
Gunicorn, running as a systemd service. Sized for a 2 vCPU / 4GB RamNode
KVM instance; bump PostgreSQL shared_buffers and worker counts for
larger fleets.
0. Assumptions
- Fresh Ubuntu 24.04 LTS VPS, non-root sudo user
- Hostname resolvable (e.g.
netbox.ramnode.internalor public FQDN with A record) - Latest stable NetBox release at time of writing tracks the
v4.xbranch — check https://github.com/netbox-community/netbox/releases and adjustVERSIONbelow
1. Base packages
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3 python3-pip python3-venv python3-dev \
build-essential libxml2-dev libxslt1-dev libffi-dev libpq-dev \
libssl-dev zlib1g-dev git redis-server curl2. PostgreSQL
RamNode's Ubuntu 24.04 image ships PostgreSQL 16 in the default repos.
sudo apt install -y postgresql postgresql-contrib
sudo systemctl enable --now postgresqlCreate DB and user:
sudo -u postgres psql <<'EOF'
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'CHANGE_ME_STRONG_PW';
ALTER DATABASE netbox OWNER TO netbox;
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\c netbox
GRANT ALL ON SCHEMA public TO netbox;
EOFVerify:
psql --username netbox --password --host localhost netbox -c "SELECT 1;"3. Redis
Already installed above. Confirm it's up and not exposed off-loopback:
sudo systemctl enable --now redis-server
redis-cli ping # expect PONG
grep -E '^bind' /etc/redis/redis.conf # should be 127.0.0.1 only4. Fetch NetBox
sudo mkdir -p /opt/netbox
sudo chown "$USER":"$USER" /opt/netbox
cd /opt
VERSION=v4.2.3 # pin to current stable — check releases page
git clone --branch "$VERSION" --depth 1 https://github.com/netbox-community/netbox.git
sudo ln -s /opt/netbox /opt/netbox/current 2>/dev/null || trueCreate the dedicated system user NetBox expects:
sudo adduser --system --group netbox
sudo chown --recursive netbox /opt/netbox/media /opt/netbox/reports /opt/netbox/scripts 2>/dev/null5. Configuration
cd /opt/netbox/netbox/netbox/
cp configuration_example.py configuration.pyGenerate a secret key:
python3 /opt/netbox/netbox/netbox/generate_secret_key.pyEdit configuration.py:
ALLOWED_HOSTS = ['netbox.example.com', '<vps-public-ip>']
DATABASE = {
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'CHANGE_ME_STRONG_PW',
'HOST': 'localhost',
'PORT': '',
'CONN_MAX_AGE': 300,
}
REDIS = {
'tasks': {
'HOST': 'localhost',
'PORT': 6379,
'PASSWORD': '',
'DATABASE': 0,
'SSL': False,
},
'caching': {
'HOST': 'localhost',
'PORT': 6379,
'PASSWORD': '',
'DATABASE': 1,
'SSL': False,
},
}
SECRET_KEY = '<paste generated key>'6. Install app + run migrations
NetBox ships an upgrade script that handles venv creation, pip installs, migrations, and static collection in one pass:
cd /opt/netbox
sudo ./upgrade.shThis creates /opt/netbox/venv. Activate it for the remaining manual steps:
source /opt/netbox/venv/bin/activate
cd /opt/netbox/netboxCreate the superuser:
python3 manage.py createsuperuser7. Gunicorn + systemd
cd /opt/netbox
sudo cp contrib/gunicorn.py /opt/netbox/gunicorn.py
sudo cp contrib/netbox.service contrib/netbox-rq.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now netbox netbox-rq
sudo systemctl status netbox --no-pagerCheck logs if it fails to bind:
journalctl -u netbox -n 50 --no-pager8. Nginx (TLS-terminated reverse proxy)
sudo apt install -y nginx
sudo cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox
sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox
sudo rm -f /etc/nginx/sites-enabled/defaultEdit /etc/nginx/sites-available/netbox, set server_name to your FQDN,
and point ssl_certificate/ssl_certificate_key at real certs. If you
don't have certs yet, use certbot:
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d netbox.example.comThen:
sudo nginx -t
sudo systemctl reload nginx9. Firewall
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw enableIf RamNode's network doesn't use ufw/iptables directly and you're behind their perimeter firewall/security groups instead, open 80/443 there and skip ufw for the app tier.
10. Housekeeping
sudo systemctl enable --now netbox-housekeeping.timerif present in your version's contrib dir — runs nightly cleanup (expired sessions, changelog pruning).- Add a cron/backup job for
pg_dump netboxbefore any upgrade. - Upgrades:
git fetch --tags, checkout new tag, re-runupgrade.sh, restartnetbox+netbox-rq.
11. Smoke test
curl -Ik https://netbox.example.com/Expect 200 OK (or 302 to /login/). Log in with the superuser account
and confirm the dashboard loads.
