Any particular reason for using json.loads there, instead of the simpler:
ALLOWED_HOSTS = ['*']
? Presumably you also have "import json" earlier in the file?
Can you explain why you have two netbox "instances" using the same backend database and redis? The normal way to scale Netbox is just to change the number of gunicorn workers. Is this for some redundancy/failover scenario?
I'm just trying to get to the bottom of what's different between your config and a standard one.
If you do:
cd /opt/netbox/netbox/netbox
then it may give some clues.
One other thing to check is for misconfiguration of your front-end proxy (apache2 or nginx) on one of the instances; it may not be passing the Host: or X-Forwarded-Host: header through.