Pre-requisite
Using Proxmox VE (PVE) Helper-Script
Installation
var_net="192.168.1.26/24" \
var_gateway="192.168.1.4" \
var_ns="-nameserver=192.168.1.23" \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/netbox.sh)"Access
https://192.168.1.26 NOTE: Apache2 handling :80 and :443
Location of config file
/opt/netbox/netbox/netbox/configuration.py
Show login and database credentials
cat netbox.credsNetBox Re-issue a self-signed cert that works for IP and/or hostname
Original CA
- Cert: /etc/ssl/certs/netbox.crt
- Key: /etc/ssl/private/netbox.key (don’t copy this off the NetBox LXC)
Confirm whether it’s self-signed
root@netbox:~# openssl x509 -in /etc/ssl/certs/netbox.crt -noout -subject -issuer
subject=C=US, O=NetBox, OU=Certificate, CN=localhost
issuer=C=US, O=NetBox, OU=Certificate, CN=localhostIf subject == issuer, treat /etc/ssl/certs/netbox.crt as the CA. As you can found CN=localhost
Back up Original CA
cp -a /etc/ssl/certs/netbox.crt /etc/ssl/certs/netbox.crt.bak.$(date +%F)
cp -a /etc/ssl/private/netbox.key /etc/ssl/private/netbox.key.bak.$(date +%F)Generate New CA
openssl req -x509 -nodes -days 825 -newkey rsa:2048 \
-keyout /etc/ssl/private/netbox.key \
-out /etc/ssl/certs/netbox.crt \
-subj "/C=US/O=NetBox/OU=Certificate/CN=netbox.testbed.com" \
-addext "subjectAltName=DNS:netbox.testbed.com,IP:192.168.1.26"NOTE:
- CN=netbox.testbed.com is there because the certificate needs an identity. Historically TLS used the Common Name, but modern clients
- validate the SAN (Subject Alternative Name). In our command, the SAN is the part that really matters:
- subjectAltName=DNS:netbox.example.com,IP:192.168.1.26
- Pick the CN to match the primary name you plan to use (usually the hostname), but as long as SAN is correct, CN is mostly cosmetic.
Set Apache vhost as ServerName netbox.testbed.com
-
Edit the vhost (set the name in both *:80 and *:443 blocks)
vi /etc/apache2/sites-available/netbox.conf
Make sure it includes: ServerName netbox.example.com
-
Reload Apache (after checking config)
apachectl configtest systemctl reload apache2
-
Verify which vhost is active
apachectl -SImportant: for clients to reach https://netbox.example.com, that name must resolve to 192.168.1.26 (via PowerDNS or a client /etc/hosts entry).
https://community-scripts.github.io/ProxmoxVE/scripts?id=netbox
Setting Up NetBox (Ubuntu 24.04/22.04)
This guide walks you through installing NetBox directly on an Ubuntu LXC or VM (“bare metal” style).
System Requirements
- RAM: 4GB recommended (2GB minimum for very small labs).
- Disk: 20GB recommended (10GB minimum).
- CPU: 2 vCPUs recommended.
1. System Preparation
Update the system and install the required system packages, including PostgreSQL, Redis, and Python build tools.
apt update && apt upgrade -y
apt install -y postgresql postgresql-common postgresql-client redis-server \
git python3-pip python3-venv python3-dev build-essential libxml2-dev \
libxslt1-dev libffi-dev libpq-dev libssl-dev zlib1g-dev2. Database Setup (PostgreSQL)
-
Start PostgreSQL:
systemctl enable --now postgresql -
Create Database and User: Replace strong_password with a real password.
sudo -u postgres psqlInside the SQL shell:
CREATE DATABASE netbox WITH TEMPLATE template0 ENCODING 'UTF8'; CREATE USER netbox WITH PASSWORD 'strong_password'; ALTER DATABASE netbox OWNER TO netbox; \c netbox ALTER SCHEMA public OWNER TO netbox; GRANT ALL PRIVILEGES ON SCHEMA public TO netbox; \q
3. Install NetBox
-
Create the NetBox system user:
useradd -r -d /opt/netbox -s /usr/sbin/nologin netbox -
Clone the NetBox repository:
git clone -b main https://github.com/netbox-community/netbox.git /opt/netbox/ chown -R netbox:netbox /opt/netbox/ -
Configure NetBox:
cd /opt/netbox/netbox/netbox/ cp configuration_example.py configuration.pyGenerate a secret key:
root@netbox:/opt/netbox/netbox/netbox# python3 -c 'import secrets; print(secrets.token_hex(50))' 866887ae9b6f118ce7e5a7b7f7a4b2fa7a1979dab810e8b092dd5dba4a3bc1f6b0e1028ac45850c1b55a617c3ff41c932c56Edit `configuration.py` (located in `/opt/netbox/netbox/netbox/`):
- Set `ALLOWED_HOSTS` to `[’**’]` for initial testing. ***(For production, replace `*` with your NetBox server’s IP addresses or domain names)****:
ALLOWED_HOSTS = ['*'] - Set `DATABASE` user to `netbox` and password to `strong_password`.
- Set `SECRET_KEY` to the string generated above.
- Set `ALLOWED_HOSTS` to `[’**’]` for initial testing. ***(For production, replace `*` with your NetBox server’s IP addresses or domain names)****:
-
Install Dependencies & Run Migrations:
/opt/netbox/upgrade.shThis script creates the Python environment, installs requirements, and builds the DB schema.
-
Create a Superuser:
source /opt/netbox/venv/bin/activate cd /opt/netbox/netbox python3 manage.py createsuperuser
4. Configure Gunicorn & Systemd
-
Copy the systemd service and config files:
cp /opt/netbox/contrib/*.service /etc/systemd/system/ cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py systemctl daemon-reload -
Start NetBox Services:
systemctl enable --now netbox netbox-rq
5. Web Server (Nginx)
To serve NetBox on port 80/443.
-
Install Nginx:
apt install -y nginx -
Configure Nginx: Copy the default config provided by NetBox:
cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox rm /etc/nginx/sites-enabled/default ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox -
Edit the Nginx Config: Edit /etc/nginx/sites-available/netbox. Change server_name to your IP or Domain.
-
Generate Self-Signed SSL Certificate: The default config enables HTTPS, so you need a certificate.
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ -keyout /etc/ssl/private/netbox.key \ -out /etc/ssl/certs/netbox.crt \ -subj "/C=US/ST=State/L=City/O=NetBox/CN=netbox.local" -
Restart Nginx:
systemctl restart nginx
Accessing NetBox
- Open `<http://
/>` - Log in with the superuser you created.
Reference List
- https://netbox.readthedocs.io/en/stable/installation/3-netbox/
- https://www.apalrd.net/posts/2025/iaac_netbox/
- https://www.youtube.com/watch?v=p3J3f2QWFGE
- https://www.howtoforge.com/how-to-install-netbox-irm-on-ubuntu-24-04-server/#google_vignette
- https://community-scripts.github.io/ProxmoxVE/scripts?id=netbox&category=Network+%26+Firewall