netbox
netbox copied to clipboard
Support Redis Unix sockets
NetBox version
3.7.5
Feature type
Change to existing functionality
Proposed functionality
Support Redis connectivity through Unix sockets
Use case
Binding to Redis servers on localhost or sidecars without exposing a TCP listener.
Database changes
No response
External dependencies
No response
https://github.com/netbox-community/netbox/issues/15955 https://github.com/netbox-community/netbox/issues/4377 https://github.com/netbox-community/netbox/pull/15590
From previous tickets:
Proposed Functionality
Implement unix-socket support for Redis cache and webhook
Use Case
When Redis is installed on the same Server as netbox, then the possible usage of unix sockets for redis would be nice. When using unix sockets, there is no need for localhost loopback with the whole IP-Stack. The usage with unix sockets can improve the performance too (even if it doesn't matter).
Database Changes
No DB-Changes needed. Just some small changes in settings.py and configuration.py
Hello, I have a patch that I'm willing to upstream that was made to support Redis Unix sockets.
(Note: the linked patch also modifies STATIC_ROOT, but this modification is not part of the proposed changes)
This patch defines new REDIS['tasks']['URL'] and REDIS['caching']['URL'] settings, which take priority if defined by the user. The user can then set this config if they want to use Unix sockets:
REDIS = {
"tasks": {"URL": "unix:///run/redis-netbox/redis.sock?db=0", "SSL": False},
"caching": {"URL": "unix:///run/redis-netbox/redis.sock?db=1", "SSL": False},
}
In the case of the tasks Redis database, if and only if URL is defined, NetBox would use it.
In the case of the caching Redis database, URL is always used, but defaults to the value that was used before the patch.
This should be backwards compatible.
@minijackson sounds good, I'll assign this to you for a PR. Thanks!
@minijackson are you still interested in working on this?
Yes, sorry. Went on a quick vacation, then that task fell through the cracks. I'll submit a PR soon.