Proxbox backend docker support
Hi,
so far I can not setup Proxbox backend. If anyone found some workaround please let me know. I am thinking about creating a new docker instance with Proxbox backend only. What do you think? I would need some help for this.
docker exec -it --user root netbox-docker-netbox-1 /bin/bash
root@1c82s1na6115:/opt/netbox/netbox#
root@1c82s1na6115:/opt/netbox/netbox#
root@1c82s1na6115:/opt/netbox/netbox# sudo cp -v /opt/netbox/netbox/netbox-proxbox/contrib/*.service /etc/systemd/system/
bash: sudo: command not found
root@1c82s1na6115:/opt/netbox/netbox# cp -v /opt/netbox/netbox/netbox-proxbox/contrib/*.service /etc/systemd/system/
cp: cannot stat '/opt/netbox/netbox/netbox-proxbox/contrib/*.service': No such file or directory
root@1c82s1na6115:/opt/netbox/netbox# vi
bash: vi: command not found
root@1c82s1na6115:/opt/netbox/netbox# nano
bash: nano: command not found
root@1c82s1na6115:/opt/netbox/netbox# apt install nano
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
hunspell
The following NEW packages will be installed:
nano
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 282 kB of archives.
After this operation, 856 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 nano amd64 7.2-2ubuntu0.1 [282 kB]
Fetched 282 kB in 0s (1187 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package nano.
(Reading database ... 9698 files and directories currently installed.)
Preparing to unpack .../nano_7.2-2ubuntu0.1_amd64.deb ...
Unpacking nano (7.2-2ubuntu0.1) ...
Setting up nano (7.2-2ubuntu0.1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group editor) doesn't exist
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pico.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group pico) doesn't exist
root@1c82s1na6115:/opt/netbox/netbox# nano -w /etc/systemd/system/proxbox.service
root@1c82s1na6115:/opt/netbox/netbox# systemctl daemon-reload
bash: systemctl: command not found
root@1c82s1na6115:/opt/netbox/netbox# systemctl start proxbox
bash: systemctl: command not found
root@1c82s1na6115:/opt/netbox/netbox# cd ..
root@1c82s1na6115:/opt/netbox# ls venv/bin/
Activate.ps1 activate.csh dul-receive-pack ghp-import markdown-it mkdocs-get-deps pip pybabel pyrsa-encrypt pyrsa-sign python3 qr rqworker strawberry
__pycache__ activate.fish dul-upload-pack jp.py markdown_py netaddr pip3 pygmentize pyrsa-keygen pyrsa-verify python3.12 rq sqlformat watchmedo
activate django-admin dulwich jsonschema mkdocs normalizer pip3.12 pyrsa-decrypt pyrsa-priv2pub python pytkdocs rqinfo stone wheel
#176
#40
django.core.exceptions.ImproperlyConfigured: Requested setting FIELD_CHOICES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
(venv) root@1c82s1na6115:/opt/netbox/netbox/netbox# /opt/netbox/venv/bin/uvicorn netbox-proxbox.netbox_proxbox.main:app --host 0.0.0.0 --port 8800 --app-dir /opt/netbox/netbox --reload
INFO: Will watch for changes in these directories: ['/opt/netbox/netbox/netbox']
INFO: Uvicorn running on http://0.0.0.0:8800 (Press CTRL+C to quit)
INFO: Started reloader process [993] using WatchFiles
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/configuration.bac.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
Process SpawnProcess-1:
Traceback (most recent call last):
File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/lib/python3.12/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/opt/netbox/venv/lib/python3.12/site-packages/uvicorn-0.32.0-py3.12.egg/uvicorn/_subprocess.py", line 80, in subprocess_started
target(sockets=sockets)
File "/opt/netbox/venv/lib/python3.12/site-packages/uvicorn-0.32.0-py3.12.egg/uvicorn/server.py", line 65, in run
return asyncio.run(self.serve(sockets=sockets))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
File "/opt/netbox/venv/lib/python3.12/site-packages/uvicorn-0.32.0-py3.12.egg/uvicorn/server.py", line 69, in serve
await self._serve(sockets)
File "/opt/netbox/venv/lib/python3.12/site-packages/uvicorn-0.32.0-py3.12.egg/uvicorn/server.py", line 76, in _serve
config.load()
File "/opt/netbox/venv/lib/python3.12/site-packages/uvicorn-0.32.0-py3.12.egg/uvicorn/config.py", line 434, in load
self.loaded_app = import_from_string(self.app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/uvicorn-0.32.0-py3.12.egg/uvicorn/importer.py", line 19, in import_from_string
module = importlib.import_module(module_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/main.py", line 7, in <module>
from netbox_proxbox.backend.exception import ProxboxException
File "/opt/netbox/venv/lib/python3.12/site-packages/netbox_proxbox/backend/__init__.py", line 1, in <module>
from netbox_proxbox.backend.routes.netbox.virtualization.cluster_type import ClusterType
File "/opt/netbox/venv/lib/python3.12/site-packages/netbox_proxbox/backend/routes/netbox/__init__.py", line 6, in <module>
from netbox_proxbox.backend.session.netbox import NetboxSessionDep
File "/opt/netbox/venv/lib/python3.12/site-packages/netbox_proxbox/backend/session/netbox.py", line 14, in <module>
from netbox.settings import BASE_PATH
File "/opt/netbox/netbox/netbox/settings.py", line 799, in <module>
plugin = importlib.import_module(plugin_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/netbox_dns/__init__.py", line 5, in <module>
from ipam.choices import IPAddressStatusChoices
File "/opt/netbox/netbox/ipam/choices.py", line 21, in <module>
class PrefixStatusChoices(ChoiceSet):
File "/opt/netbox/netbox/utilities/choices.py", line 24, in __new__
if replace_key and replace_key in settings.FIELD_CHOICES:
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/__init__.py", line 89, in __getattr__
self._setup(name)
File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/__init__.py", line 69, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting FIELD_CHOICES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
^CINFO: Stopping reloader process [993]
I have this working on a stack, I'm using Traefik to proxy requests through to the FastAPI, works flawlessly that way.
I use a Dockerfile to build off the netbox base image, then run that image with;
command:
- /opt/netbox/venv/bin/uvicorn
- netbox-proxbox.netbox_proxbox.main:app
- --host
- "0.0.0.0"
- --port
- "8800"
- --app-dir
- /opt/netbox/netbox
- --reload
Then let Traefik proxy through to 8800 on that container.
Hello @Uzoma8Chi, I will work on this issue.
@Uzoma8Chi could please try using a new container I've just created?
Pull the image
docker pull emersonfelipesp/proxbox-api:latest
Run the container using the image listening on all host network interfaces and HTTP port 8800
docker run -d -p 8800:8800 --name proxbox-api emersonfelipesp/proxbox-api:latest
If container starts correctly, you should be able to access http://<YOUR-IP:8800/docs, which is the API docs of the backend.
I have also added more instructions here: https://github.com/netdevopsbr/netbox-proxbox/tree/develop/proxbox_api
I tried but I got an error "Connection reset by peer." I also see no logs ("docker logs proxbox-api"). I think SSL cert is missing. Proxbox-api can also be accessible only by localhost so we won't need SSL.
I tried but I got an error "Connection reset by peer." I also see no logs ("docker logs proxbox-api"). I think SSL cert is missing. Proxbox-api can also be accessible only by localhost so we won't need SSL.
I think you could try testing it with python3 manage.py runserver --insecure to bypass this SSL failure.
I'm working on docs to establish secure peer-to-peer communcation between NetBox and proxbox-api
I think something is still missing.
docker exec -it --user root proxbox-api /bin/bash
root@5246f15ba7c6:/app# ls
database.db
root@5246f15ba7c6:/app# uv run fastapi run --host 0.0.0.0 --port 8800
bash: uv: command not found
root@5246f15ba7c6:/app# pip install -e .
Obtaining file:///app
[notice] A new release of pip is available: 24.3.1 -> 25.0.1
[notice] To update, run: pip install --upgrade pip
ERROR: file:///app does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
root@5246f15ba7c6:/app# fastapi run --host 0.0.0.0 --port 8800
FastAPI Starting production server 🚀
Searching for package file structure from directories with __init__.py files
Could not find a default file to run, please provide an explicit path
root@5246f15ba7c6:/app# uvicorn main:app --host 0.0.0.0 --port 8800
ERROR: Error loading ASGI app. Could not import module "main".
root@5246f15ba7c6:/app# git clone https://github.com/netdevopsbr/netbox-proxbox.git
bash: git: command not found
root@5246f15ba7c6:/app# python3 manage.py runserver --insecure
python3: can't open file '/app/manage.py': [Errno 2] No such file or directory
The python3 manage.py runserver --insecure is to start NetBox service, not proxbox-api.
If running proxbox-api using Docker, just start the docker should work.
Example:
cd /opt/netbox/netbox
python3 manage.py runserver 0.0.0.0:8000 --insecure
Then you'll have NetBox running using HTTP on port 8000. Next step is chaning NetBox Endpoint object on Proxbox plugin to also point to port 8000/http.
Then just run the container. NetBox via the plugin will automatically update proxbox backend sqlite database with the new port.
Thank you. I did manage to run container using the image you provided. I am able to access API docs. I get some errors in browser but that is probably another issue. ''' Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.0.5:8800/proxmox/sessions?source=netbox&list_all=false&plugin_name=netbox_proxbox&domain=192.168.0.5/32. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200. '''
Thank you. I did manage to run container using the image you provided. I am able to access API docs. I get some errors in browser but that is probably another issue. ''' Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.0.5:8800/proxmox/sessions?source=netbox&list_all=false&plugin_name=netbox_proxbox&domain=192.168.0.5/32. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200. '''
@Uzoma8Chi I'm right now resolving this issue. If you wish, you can wait for v0.0.6b2 to use with docker container, or wait me to finish it and use directly from github repository.
Generate CORS origins based on user provided information at NetBox Endpoint.
The above issue will solve it for docker. But you can already pull the git repository and use the plugin without this CORS error.
I will close this issue as the problem now is not related to docker itself. Container: https://hub.docker.com/r/emersonfelipesp/proxbox-api