Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access static files for the custom basepath #512

Closed
Arbuzov opened this issue Jan 23, 2025 · 9 comments
Closed

Unable to access static files for the custom basepath #512

Arbuzov opened this issue Jan 23, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@Arbuzov
Copy link

Arbuzov commented Jan 23, 2025

The Helm chart version

netbox-5.0.22, netbox-5.0.18

Environment Versions

Kubernetes: 1.27.4

Custom chart values

global:
  storageClass: "local-path"
persistence:
  storageClass: "local-path"
postgresql:
  enabled: true
  primary:
    resources:
      requests:
        memory: "2Gi"
        cpu: "750m"
      limits:
        memory: "2Gi"
        cpu: "750m"
ingress:
  enabled: true
  className: "nginx"
  hosts:
    - host: ""
      paths:
        - /netbox
basePath: netbox/

Current Behavior & Steps to Reproduce

Deployed with the:

helm upgrade --install --namespace netbox --create-namespace --values values.yaml netbox netbox/netbox

Can`t access static files via external IP getting:

http://myip/netbox/media-failure/?filename=setmode.js

Can`t get static via proxy access:

http://localhost:58447/netbox/media-failure/?filename=setmode.js

Access without the prefix works well:

http://localhost:58447/static/setmode.js

I have tried to add STATIC_URL: /netbox/static/ into configmap netbox.yaml as it was suggested on the page. No success.

Expected Behavior

Static file should be available

NetBox Logs

🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
💡 Superuser Username: admin, E-Mail: admin@example.com
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
✅ Initialisation is done.
⏳ Waiting for control socket to be created... (1/10)
2025/01/23 09:55:33 [warn] 7#7 Unit is running unprivileged, then it cannot use arbitrary user and group.
2025/01/23 09:55:33 [info] 7#7 unit 1.34.1 started
2025/01/23 09:55:33 [info] 102#102 discovery started
2025/01/23 09:55:33 [notice] 102#102 module: python 3.12.3 "/usr/lib/unit/modules/python3.12.unit.so"
2025/01/23 09:55:33 [info] 7#7 controller started
2025/01/23 09:55:33 [notice] 7#7 process 102 exited with code 0
2025/01/23 09:55:33 [info] 104#104 router started
2025/01/23 09:55:33 [info] 104#104 OpenSSL 3.0.13 30 Jan 2024, 300000d0
⚙️ Applying configuration from /etc/unit/nginx-unit.json
2025/01/23 09:55:34 [info] 107#107 "netbox" prototype started
2025/01/23 09:55:34 [info] 108#108 "netbox" application started
✅ Unit configuration loaded successfully
2025/01/23 09:55:37 [notice] 7#7 process 100 exited with code 0
2025/01/23 09:55:40 [info] 155#155 "netbox" application started
2025/01/23 09:55:50 [info] 178#178 "netbox" application started
10.244.1.1 - - [23/Jan/2025:09:55:59 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:00 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:00 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:06 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:10 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:10 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:20 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:20 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:30 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:30 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:40 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:40 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:50 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:56:50 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:57:00 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:57:00 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.0.0 - - [23/Jan/2025:09:57:06 +0000] "GET /netbox/ HTTP/1.1" 200 37304 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
2025/01/23 09:57:06 [info] 201#201 "netbox" application started
10.244.0.0 - - [23/Jan/2025:09:57:06 +0000] "GET /netbox/static/netbox.css?v=4.2.2 HTTP/1.1" 404 9874 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
10.244.0.0 - - [23/Jan/2025:09:57:06 +0000] "GET /netbox/static/netbox.js?v=4.2.2 HTTP/1.1" 404 9871 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
10.244.0.0 - - [23/Jan/2025:09:57:06 +0000] "GET /netbox/static/logo_netbox_dark_teal.svg HTTP/1.1" 404 9919 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
10.244.0.0 - - [23/Jan/2025:09:57:06 +0000] "GET /netbox/static/logo_netbox_bright_teal.svg HTTP/1.1" 404 9925 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
10.244.0.0 - - [23/Jan/2025:09:57:07 +0000] "GET /netbox/static/netbox-external.css?v=4.2.2 HTTP/1.1" 404 9901 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
10.244.1.1 - - [23/Jan/2025:09:57:10 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:57:10 +0000] "GET /netbox/login/ HTTP/1.1" 200 3361 "-" "kube-probe/1.27"
10.244.1.1 - - [23/Jan/2025:09:57:20 +0000] "GET /status/applications/netbox/processes/running HTTP/1.1" 200 3 "-" "kube-probe/1.27"
10.244.0.0 - - [23/Jan/2025:09:57:24 +0000] "GET /netbox/static/setmode.js?v=4.2.2 HTTP/1.1" 404 9874 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
10.244.0.0 - - [23/Jan/2025:09:57:24 +0000] "GET /netbox/media-failure/?filename=setmode.js HTTP/1.1" 200 2147 "http://192.168.67.56/netbox/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
@Arbuzov Arbuzov added the bug Something isn't working label Jan 23, 2025
@LeoColomb LeoColomb changed the title Can`t access static files for the custom basepath Can't access static files for the custom basepath Jan 23, 2025
@LeoColomb LeoColomb changed the title Can't access static files for the custom basepath Unable to access static files for the custom basepath Jan 23, 2025
@LeoColomb
Copy link
Member

Thanks for filing this issue, @Arbuzov.
I suspect an issue related to netbox-community/netbox#18401
Could you try to use NetBox version 4.1.x using the following values?

image:
  tag: "v4.1.11"

@bcskda
Copy link

bcskda commented Jan 26, 2025

As a workarkound, I created another Ingress with rewrite rule: /netbox/static/ -> /netbox/ - this might help

@Arbuzov
Copy link
Author

Arbuzov commented Jan 27, 2025

@bcskda
This extra ingress helped:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: netbox-static-ingress
  namespace: netbox
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /static/$1
spec:
  ingressClassName: "nginx"
  rules:
  - host: ''
    http:
      paths:          
      - pathType: Prefix
        path: /netbox/static/(.*)
        backend:
          service:
            name: netbox
            port: 
              number: 80

@Sharvesh0306
Copy link

@bcskda This extra ingress helped:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: netbox-static-ingress
  namespace: netbox
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /static/$1
spec:
  ingressClassName: "nginx"
  rules:
  - host: ''
    http:
      paths:          
      - pathType: Prefix
        path: /netbox/static/(.*)
        backend:
          service:
            name: netbox
            port: 
              number: 80

Shouldnt pathType be ImplementationSpecific for regex to work?

@Sharvesh0306
Copy link

I tried the ingress route and I'm still getting the error

@LeoColomb
Copy link
Member

@Sharvesh0306 As an alternative, you may try what was my suggestion for initial investigation.

Thanks for filing this issue, @Arbuzov.
I suspect an issue related to netbox-community/netbox#18401
Could you try to use NetBox version 4.1.x using the following values?

image:
  tag: "v4.1.11"

@Sharvesh0306
Copy link

@LeoColomb Looks like the issue was resolved in 5.0.23 update. I was able to rollout the deployment successfully.

Thanks for your help.

@LeoColomb
Copy link
Member

Thanks for the reply @Sharvesh0306.
Closing as fixed by 5.0.23.

@diepes
Copy link

diepes commented Jan 31, 2025

I was able to get netbox hosted at sub path /netbox by disabling ingress and using Traefik as ingress.
Should work with nginx ingress would just need two configs.

The idea is to not strip the /netbox prefix for most of the site using basePath: netbox/ but for /netbox/static we do strip the /netbox prefix.

Probably something to be fixed in the static webserver ? Ignoring the basePath: setting ?

extract from values.yaml

#
basePath: "netbox/" 
ingress:
  enabled: false
extraDeploy:
  - |
    ---
    apiVersion: traefik.containo.us/v1alpha1
    kind: IngressRoute
    metadata:
      labels:
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/name: network-monitor-netmon
      name: network-monitor-netmon
      namespace: dev
    spec:
      entryPoints:
        - websecure
      routes:
        - kind: Rule
          match: Host(`dev-aks.test.com`) && PathPrefix(`/netbox/static`)
          middlewares:
            - name: network-monitor-netmon-strip-prefix
          services:
            - kind: Service
              name: network-monitor-netbox
              port: 80
        - kind: Rule
          match: Host(`dev-aks.test.com`) && PathPrefix(`/netbox`)
          # middlewares:
          #   - name: network-monitor-netmon-strip-prefix
          services:
            - kind: Service
              name: network-monitor-netbox
              port: 80
      tls: {}
    ---
  - |
    ---
    apiVersion: traefik.containo.us/v1alpha1
    kind: Middleware
    metadata:
      annotations:
      name: network-monitor-netmon-strip-prefix
      namespace: dev
    spec:
      stripPrefix:
        prefixes:
        - /netbox
    ---

## 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants