Skip to content

Instantly share code, notes, and snippets.

@jackyscript
Forked from Harry-Chen/README.md
Created June 18, 2024 14:37
Show Gist options
  • Save jackyscript/c544e622347fa59983c8653ee52f734b to your computer and use it in GitHub Desktop.
Save jackyscript/c544e622347fa59983c8653ee52f734b to your computer and use it in GitHub Desktop.
NetBox Docker deployment under sub-directory

Assume your deployment is under /netbox:

Add to configuration/configuration.py

BASE_PATH = environ.get('BASE_PATH', '')

Add to env/netbox.env

BASE_PATH=/netbox

Then merge this with your own docker-compose.override.yml (or create one if not existed) to make health checker of Docker happy:

version: '3.4'
services:
  netbox:
    healthcheck:
      test: "curl -f http://localhost:8080/netbox/api/ || exit 1"

Outside NGINX config:

upstream netbox {
  server 127.0.0.1:8080; # or your own NetBox port
}

server {
  listen 80;
  
  location /netbox {
    proxy_pass http://netbox;
  }
  
  location /netbox/static {
    proxy_pass http://netbox/static/;
  }
}

The trick is to strip BASE_PATH on any requests to static resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment