netbox-docker: Configuring BASE_PATH does not works

Current Behavior

After setting the base URL path to BASE_PATH = 'test/' the error about Static Media Failure is raised.

image

Expected Behavior

  • Netbox app should run without a problem
  • Static files should be referenced according to BASE_PATH.

Docker Compose Version

1.29.2

Docker Version

Client: Docker Engine - Community
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:54:22 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:31 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The git Revision

6a52a48b71187eabb16db2149060cffc159f5f72

The git Status

On branch release
Your branch is up to date with 'origin/release'.

Startup Command

docker compose up

NetBox Logs

Starting netbox-docker_redis-cache_1 ... done
Starting netbox-docker_postgres_1    ... done
Starting netbox-docker_redis_1       ... done
Starting netbox-docker_netbox-housekeeping_1 ... done
Starting netbox-docker_netbox-worker_1       ... done
Starting netbox-docker_netbox_1              ... done
Attaching to netbox-docker_postgres_1, netbox-docker_redis-cache_1, netbox-docker_redis_1, netbox-docker_netbox-worker_1, netbox-docker_netbox-housekeeping_1, netbox-docker_netbox_1
netbox-housekeeping_1  | Interval set to 86400 seconds
netbox-worker_1        | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox-housekeeping_1  | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox-worker_1        | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox-worker_1        | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox-housekeeping_1  | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox-worker_1        | 🧬 loaded config '/etc/netbox/config/plugins.py'
netbox-housekeeping_1  | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox-housekeeping_1  | 🧬 loaded config '/etc/netbox/config/plugins.py'
netbox-housekeeping_1  | [*] Clearing expired authentication sessions
netbox-housekeeping_1  |        Sessions cleared.
netbox-housekeeping_1  | [*] Checking for expired changelog records
netbox-housekeeping_1  |        No expired records found.
netbox-housekeeping_1  | [*] Checking for latest release
netbox-housekeeping_1  |        Latest release: 3.0.9
netbox-housekeeping_1  | Finished.
netbox_1               | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/plugins.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/plugins.py'
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/000_users.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/010_groups.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/015_object_permissions.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/020_custom_fields.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/020_tags.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/020_tenant_groups.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/030_regions.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/030_tenants.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/040_sites.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/050_manufacturers.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/060_device_types.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/070_rack_roles.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/075_locations.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/080_racks.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/090_device_roles.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/100_platforms.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/130_cluster_types.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/135_cluster_groups.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/135_clusters.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/140_clusters.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/140_devices.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/150_rirs.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/160_aggregates.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/165_cluster_groups.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/175_route_targets.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/180_vrfs.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/190_prefix_vlan_roles.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/200_vlan_groups.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/210_vlans.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/220_prefixes.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/230_virtual_machines.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/240_virtualization_interfaces.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/250_dcim_interfaces.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/260_ip_addresses.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/270_primary_ips.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/280_custom_links.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/280_providers.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/290_circuit_types.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/290_webhooks.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/300_circuits.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/320_services.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/330_power_panels.py
netbox_1               | ▶️  Running the startup script /opt/netbox/startup_scripts/340_power_feeds.py
netbox_1               | ✅ Initialisation is done.
netbox_1               | 2021/11/11 06:45:35 [warn] 7#7 Unit is running unprivileged, then it cannot use arbitrary user and group.
netbox_1               | 2021/11/11 06:45:35 [info] 7#7 unit started
netbox_1               | 2021/11/11 06:45:35 [info] 16#16 discovery started
netbox_1               | 2021/11/11 06:45:35 [notice] 16#16 module: python 3.9.5 "/usr/lib/unit/modules/python3.unit.so"
netbox_1               | 2021/11/11 06:45:35 [info] 7#7 controller started
netbox_1               | 2021/11/11 06:45:35 [notice] 7#7 process 16 exited with code 0
netbox_1               | 2021/11/11 06:45:35 [info] 18#18 router started
netbox_1               | 2021/11/11 06:45:35 [info] 18#18 OpenSSL 1.1.1l  24 Aug 2021, 101010cf
netbox_1               | 2021/11/11 06:45:35 [info] 19#19 "netbox" application started
netbox_1               | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/plugins.py'
netbox_1               | ⚙️ Applying configuration from /etc/unit/nginx-unit.json
netbox_1               | ✅ Unit configuration loaded successfully
netbox_1               | 2021/11/11 06:45:38 [notice] 7#7 process 14 exited with code 0
netbox_1               | 2021/11/11 06:46:49 [info] 34#34 "netbox" application started
netbox_1               | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/plugins.py'


netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:53 +0000] "GET /test/ HTTP/1.1" 200 133840 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | Not Found: /test/static/netbox-external.css
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:53 +0000] "GET /test/static/netbox-external.css HTTP/1.1" 404 7469 "http://localhost:8000/test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | Not Found: /test/static/netbox-light.css
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:53 +0000] "GET /test/static/netbox-light.css HTTP/1.1" 404 7460 "http://localhost:8000/test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | 2021/11/11 06:46:53 [info] 35#35 "netbox" application started
netbox_1               | Not Found: /test/static/netbox.js
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:53 +0000] "GET /test/static/netbox.js HTTP/1.1" 404 7439 "http://localhost:8000/test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:54 +0000] "GET /test/media-failure/?filename=netbox-light.css HTTP/1.1" 200 1836 "http://localhost:8000/test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | Not Found: /test/static/netbox_logo.svg
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:54 +0000] "GET /test/static/netbox_logo.svg HTTP/1.1" 404 7457 "http://localhost:8000/test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | 🧬 loaded config '/etc/netbox/config/configuration.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/extra.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/logging.py'
netbox_1               | 🧬 loaded config '/etc/netbox/config/plugins.py'
netbox_1               | Not Found: /favicon.ico
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:54 +0000] "GET /favicon.ico HTTP/1.1" 404 2109 "http://localhost:8000/test/media-failure/?filename=netbox-light.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | Not Found: /test/static/netbox-dark.css
netbox_1               | 172.22.0.1 - - [11/Nov/2021:06:46:56 +0000] "GET /test/static/netbox-dark.css HTTP/1.1" 404 7457 "http://localhost:8000/test/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
netbox_1               | 2021/11/11 06:48:57 [notice] 7#7 process 34 exited with code 0
netbox_1               | 2021/11/11 06:48:57 [notice] 7#7 process 35 exited with code 0

Content of docker-compose.override.yml

version: '3.4'
services:
  netbox:
    ports:
      - 8000:8080

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

From looking at the documentation for nginx unit, it doesn’t seem to support url rewriting yet, so my suggestion will not work with the netbox-docker image in most cases.

In your specific case, it seems like you want the base path to be /netbox. That might be possible like this:

{
      "match": {
        "uri": "/netbox/static/*"
      },
      "action": {
        "share": "/opt/netbox"
      }
    },

This will pass all /netbox/static/* urls to /opt/share/netbox so if you request https://netboxhost.com/netbox/static/blah.js it will be fetched from /opt/netbox + /netbox/static/blah.js which should give the right URL.

Nginx unit seems pretty limited in general, so I don’t have a good solution for you. It’s not possible to just use a subdomain for your netbox instance instead of a path?

The issue is that the match pattern configured in nginx unit for static files is static (as in, non-configurable):

https://github.com/netbox-community/netbox-docker/blob/release/docker/nginx-unit.json#L10-L16

You might be able to mount your own nginx-unit.json file to /etc/unit/nginx-unit.json with a correct route for static files.

I’ve just pulled the netbox-docker and tried to do the fresh start with BASE_PATH and the problem still occurs.