iDebugAll / nextbox-ui-plugin

A topology visualization plugin for Netbox powered by NextUI Toolkit
MIT License
469 stars 60 forks source link

403 Forbidden issue but unable to solve by issues done #91

Closed deepskybird closed 2 years ago

deepskybird commented 2 years ago

I just installed netbox in a docker environment and installed the plugin like in the documentation for docker installation. I have some devices that are connected, but the topology viewer is empty. Unfortunately #68 and #86 were unable to help me solve the problem, what should I write in the blank? ‘COPY ( ) ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin’

netbox 534a7d1fe0bf (v3.1.6) plugins 0.9.2

Dockerfile:

`ARG FROM_IMAGE=netboxcommunity/netbox ARG FROM_TAG=latest-ldap ARG FROM=${FROM_IMAGE}:${FROM_TAG} FROM ${FROM}

ENV VIRTUAL_ENV=/opt/netbox/venv ENV PATH="$VIRTUAL_ENV/bin:$PATH" COPY ./nextbox_ui_plugin /source/nextbox-ui-plugin/nextbox_ui_plugin/ COPY ./setup.py /source/nextbox-ui-plugin/ COPY ./MANIFEST.in /source/nextbox-ui-plugin/ COPY ./README.md /source/nextbox-ui-plugin/ COPY --chown 0:0 --chmod 755 ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin RUN pip3 install --no-cache-dir nextbox-ui-plugin`

Error:

netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *7 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/js/next.js") failed (13: Permission denied) netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *6 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/css/next.css") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/js/next.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/css/next.css HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/button_utils.js HTTP/1.1" 200 1504 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *6 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_app.js HTTP/1.1" 200 14227 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *7 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/js/next.js") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/js/next.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/css/next.css") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/css/next.css HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js") failed (13: Permission denied) netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43"

Could you please help?

Thx a lot :)

iDebugAll commented 2 years ago

I'm not sure about IUD and GID in your example. Check this for the netbox user and group inside the image you use. Shouldn't it be 1000:1000?

COPY --chown=1000:1000 ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin

Also try to use the default django /opt/netbox/venv/bin/python3 manage.py collectstatic instead.

deepskybird commented 2 years ago

Hello! Thx for your help, but I failed to solve it. 1000:1000 may be right, but not only (--chown=1000:1000) but also (--chown=1000:1000 --chmod 755/644) failed. And when it comes to Collect Static Files, I meet another failure.

About Permission

COPY --chown ( ) --chmod ( ) ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin no matter what I write in the blanks, the permissions of nextbox-ui-plugin and its documents never change as listed below. [root@localhost ~]# docker exec -it 534a7d1fe0bf /bin/bash bash-5.1$ ls -al total 12 drwxr-xr-x 1 root root 20 Jan 18 05:54 . drwxr-xr-x 1 root root 18 Jan 18 05:54 .. drwxr-xr-x 1 root root 39 Jan 18 05:55 circuits drwxr-xr-x 1 root root 39 Jan 18 05:55 dcim drwxr-xr-x 1 root root 63 Jan 18 05:55 extras -rwxr-xr-x 1 root root 277 Jan 18 05:51 generate_secret_key.py drwxr-xr-x 1 root root 39 Jan 18 05:55 ipam -rwxr-xr-x 1 root root 249 Jan 18 05:51 manage.py drwxrwxr-x 4 unit root 56 Jan 24 02:03 media drwxr-xr-x 1 root root 28 Jan 18 05:55 netbox drwxr-xr-x 1 root root 18 Jan 18 05:51 project-static drwxr-xr-x 2 root root 25 Jan 18 05:51 reports drwxr-xr-x 2 root root 25 Jan 18 05:51 scripts drwxr-xr-x 1 root root 31 Jan 24 01:23 static drwxr-xr-x 17 root root 4096 Jan 18 05:51 templates drwxr-xr-x 1 root root 39 Jan 18 05:55 tenancy drwxr-xr-x 1 root root 38 Jan 18 05:55 users drwxr-xr-x 1 root root 38 Jan 18 05:55 utilities drwxr-xr-x 1 root root 25 Jan 18 05:55 virtualization drwxr-xr-x 1 root root 25 Jan 18 05:55 wireless bash-5.1$ cd ./static bash-5.1$ ls -al total 7680 drwxr-xr-x 1 root root 31 Jan 24 01:23 . drwxr-xr-x 1 root root 20 Jan 18 05:54 .. drwxr-xr-x 6 root root 51 Jan 18 05:55 admin -rw-r--r-- 1 root root 1133 Jan 18 05:55 cable_trace.css -rw-r--r-- 1 root root 108636 Jan 18 05:55 config.js -rw-r--r-- 1 root root 105872 Jan 18 05:55 config.js.map drwxr-xr-x 4 root root 27 Jan 18 05:55 debug_toolbar drwxr-xr-x 3 root root 41 Jan 18 05:55 django_tables2 drwxr-xr-x 18 root root 4096 Jan 18 05:55 docs drwxr-xr-x 5 root root 193 Jan 18 05:55 drf-yasg drwxr-xr-x 2 root root 25 Jan 18 05:55 graphene_django -rw-r--r-- 1 root root 27564 Jan 18 05:55 graphiql.css -rw-r--r-- 1 root root 960413 Jan 18 05:55 graphiql.js -rw-r--r-- 1 root root 914093 Jan 18 05:55 graphiql.js.map drwxr-xr-x 3 root root 16 Jan 18 05:55 graphiql_debug_toolbar -rw-r--r-- 1 root root 1235 Jan 18 05:55 graphql.ico -rw-r--r-- 1 root root 109291 Jan 18 05:55 lldp.js -rw-r--r-- 1 root root 106584 Jan 18 05:55 lldp.js.map -rw-r--r-- 1 root root 465188 Jan 18 05:55 materialdesignicons-webfont-2ZY4X5WS.woff -rw-r--r-- 1 root root 1026176 Jan 18 05:55 materialdesignicons-webfont-EH3JD4GG.ttf -rw-r--r-- 1 root root 325244 Jan 18 05:55 materialdesignicons-webfont-KSYPMDN6.woff2 -rw-r--r-- 1 root root 1026396 Jan 18 05:55 materialdesignicons-webfont-LWDVGUDX.eot drwxr-xr-x 2 root root 4096 Jan 18 05:55 mptt -rw-r--r-- 1 root root 374410 Jan 18 05:55 netbox-dark.css -rw-r--r-- 1 root root 286568 Jan 18 05:55 netbox-external.css -rw-r--r-- 1 root root 232175 Jan 18 05:55 netbox-light.css -rw-r--r-- 1 root root 727867 Jan 18 05:55 netbox-print.css -rw-r--r-- 1 root root 1174 Jan 18 05:55 netbox.ico -rw-r--r-- 1 root root 374821 Jan 18 05:55 netbox.js -rw-r--r-- 1 root root 344331 Jan 18 05:55 netbox.js.map -rw-r--r-- 1 root root 835 Jan 18 05:55 netbox_icon.svg -rw-r--r-- 1 root root 2257 Jan 18 05:55 netbox_logo.png -rw-r--r-- 1 root root 4719 Jan 18 05:55 netbox_logo.svg -rw-r--r-- 1 root root 4054 Jan 18 05:55 netbox_touch-icon-180.png drwxr-xr-x 6 1000 1000 173 Jan 24 01:23 nextbox_ui_plugin -rw-r--r-- 1 root root 1511 Jan 18 05:55 rack_elevation.css -rw-r--r-- 1 root root 878 Jan 18 05:55 rest-api.ico drwxr-xr-x 7 root root 63 Jan 18 05:55 rest_framework -rw-r--r-- 1 root root 129226 Jan 18 05:55 status.js -rw-r--r-- 1 root root 128409 Jan 18 05:55 status.js.map -rw-r--r-- 1 root root 109 Jan 18 05:55 tint_20.png bash-5.1$ cd ./nextbox_ui_plugin bash-5.1$ dir bash: dir: command not found bash-5.1$ ls -al total 256 drwxr-xr-x 6 1000 1000 173 Jan 24 01:23 . drwxr-xr-x 1 root root 31 Jan 24 01:23 .. -rw-r--r-- 1 1000 1000 81084 Jan 24 01:14 bootstrap.bundle.min.js -rw-r--r-- 1 1000 1000 155758 Jan 24 01:14 bootstrap.min.css -rw-r--r-- 1 1000 1000 1504 Jan 24 01:14 button_utils.js drw-r--r-- 2 1000 1000 27 Jan 24 01:23 img drw-r--r-- 2 1000 1000 33 Jan 24 01:23 jquery drw-r--r-- 2 1000 1000 30 Jan 24 01:23 jquery-ui-1.12.1 -rw-r--r-- 1 1000 1000 14227 Jan 24 01:14 next_app.js drw-r--r-- 6 1000 1000 70 Jan 24 01:23 next_sources bash-5.1$ chmod 755 ./next_app.js chmod: ./next_app.js: Operation not permitted bash-5.1$ sudo chmod 755 ./next_app.js bash: sudo: command not found

_As You can see, COPY failed to change permission of documents in nextbox_uiplugin, I guess this is the key question but I am not able to find the answer.

Collect Static Files

`[root@localhost ~]# docker exec -it 534a7d1fe0bf /bin/bash bash-5.1$ /opt/netbox/venv/bin/python3 manage.py collectstatic 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'

You have requested to collect static files at the destination location as specified in your settings:

/opt/netbox/netbox/static

This will overwrite existing files! Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes Traceback (most recent call last): File "/opt/netbox/netbox/manage.py", line 10, in execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, *cmd_options) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(args, options) File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle collected = self.collect() File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect handler(path, prefixed_path, storage) File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 338, in copy_file if not self.delete_file(path, prefixed_path, source_storage): File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 291, in delete_file self.storage.delete(prefixed_path) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/files/storage.py", line 318, in delete os.remove(name) PermissionError: [Errno 13] Permission denied: '/opt/netbox/netbox/static/nextbox_ui_plugin/bootstrap.bundle.min.js'**`

bash-5.1$ cd /opt/netbox/netbox/ bash-5.1$ python3 manage.py collectstatic 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'

You have requested to collect static files at the destination location as specified in your settings:

/opt/netbox/netbox/static

This will overwrite existing files! Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes Traceback (most recent call last): File "/opt/netbox/netbox/manage.py", line 10, in execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, *cmd_options) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(args, options) File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle collected = self.collect() File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect handler(path, prefixed_path, storage) File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 338, in copy_file if not self.delete_file(path, prefixed_path, source_storage): File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 291, in delete_file self.storage.delete(prefixed_path) File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/files/storage.py", line 318, in delete os.remove(name) PermissionError: [Errno 13] Permission denied: '/opt/netbox/netbox/static/nextbox_ui_plugin/bootstrap.bundle.min.js'**

Thx a lot :)

deepskybird commented 2 years ago

Hello! Thx for your help, and I finally found my way what show the fact that I am a green-hand to solve it. First, after changing Dockerfile in nextbox-ui-plugin you should use docker build -t netbox-custom . again to recreate your image, otherwise with only docker-compose up it wouldn't renew change in Dockerfile, which confused me for a long time. Thx for your help :)