Hello, I want to told you that I really do not think that this is a problem with the Netbox software, I think it is a problem of the gunicorn,
I will begin explaining my issue, I am testing the IPv6/IPv4 only connectivity without the use of the DNS server at all to resolve the names.
So I setup everything to work with the IPv6 module and everything is working fine in the IPv4 world, I made a simple test.
So I was working with IPv6 link local address, and tried to go to http://[fe80::20c:29ff:fe45:9d8c]/ and later to test if the problem was with the link local address, I added a global unicast IPv6 address into the Linux interface and to my virtual machine adapter and I assure myself to stop the firewall of the physical machine and the VM too and disabled selinux. But I was not able to go the Netbox web page instead I was going to the NGNX default index.html page.
I tried the IPv4 address http://192.168.220.6/ and the browser went to the Netbox page, the IPv6 I was getting few errors get rid of the error after doing a few mods into the files. , but if I do an DNS query, adding to the /etc/hosts in the OS windows.
#Windows /etc/hosts
2016:fade::22 ipam.lab.local
I am using centos 7.0.
Linux ipam 3.10.0-327.36.3.el7.x86_64 #1 SMP Mon Oct 24 16:09:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
cd /opt/netbox/netbox/netbox
vim configuration.py
ALLOWED_HOSTS = ['fe80::20c:29ff:fe45:9d8c', '2016:fade::22', '192.168.220.6', 'ipam.lab.local']`
and to the file located in /etc/nginx/sites-available/netbox, put some tiher parameters missing fro the guide.
'server {
listen 80;
listen [::]:80;
server_name ipam.lab.local 192.168.220.6 2016:fade::22 fe80::20c:29ff:fe45:9d8c;
access_log off;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
`
I made some tests, That I will explain now.
To the file /etc/nginx/sites-available/netbox
I added the listen [::]:80; and changed the server_name to see the importance
`#server_name 192.168.220.6;
#server_name 192.168.220.6 fe80::20c:29ff:fe45:9d8c 2016:fade::22 ipam.lab.local;
#server_name ipam.lab.local 192.168.220.6;
server_name ipam.lab.local 2016:fade::22 fe80::20c:29ff:fe45:9d8 192.168.220.6;
#server_name 2016:fade::22;
#server_name 2016:fade::22 fe80::20c:29ff:fe45:9d8c ipam.lab.local 192.168.220.6;
location / {
#proxy_pass http://127.0.0.1:8001;
#proxy_pass http://192.168.220.6:8001;
#proxy_pass http://localhost:8001;
proxy_pass http://[::1]:8001;
#proxy_pass http://[2016:fade::22]:8001;
`
IPv6 go go to nginx default but dns IPv6 http://ipam.lab.local/ or IPv4 address http://192.168.220.6/
go to Bad Request (400)
Paramenter combination
server_name 2016:fade::22 fe80::20c:29ff:fe45:9d8c ipam.lab.local 192.168.220.6;
proxy_pass http://localhost:8001;
proxy_pass http://127.0.0.1:8001;
If i use in the gunicorn file /opt/netbox-1.7.0/gunicorn_config.py
bind = '127.0.0.1:8001'
502 Bad Gateway in the web browser using dns IPv6 http://ipam.lab.local/ or IPv4 address http://192.168.220.6/
the http://[2016:fade::22]/ is still going to nginx HTTP server default index.html
So I made all the posible combinations to see if one works but nothing to be happy.
Then I add the localhost and IPv6 loopback to the bind, uncommented
the IPv6 bind and commented the IPV4 and then it works using IPv6 DNS
and IPv4 address but the IPv6 link local or global is still going to
nginx HTTP server default index.html
only
[root@ipam ~]# vim /opt/netbox/gunicorn_config.py
command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
#bind = '127.0.0.1:8001'
bind = '[::1]:8001'
#bind = 'localhost:8001'
workers = 3
user = 'nginx'
So to by default listen to IPv4 and IPv6
proxy_pass http://[::1]:8001;
and the gunicorn_config.py bind IPv4 and IPv6 must be:
bind = '[::1]:8001'
the problem is that the directly Ipv6 addresses
http://[2016:fade::22]/
or
http://[fe80::20c:29ff:fe45:9d8c]/
Is not taking the proxy to the netbox, so what or where is the problem?
For me, it is like the netbox file with the nginx is not reading or taking in consideration the IPv6 addresses. After I discovered if I chooce Ipv6 address first and the the name and the IPv4 it gives me the Bad Request (400).
A developer friend told me that HTTP1.1 does not support IPv6
natively only HTTP2.x so he recommend me to use the DNS host to test.
./manage.py runserver [::0]:8000 --insecure.
> the problem is that the directly Ipv6 addresses
> http://[2016:fade::22]/
> or
> http://[fe80::20c:29ff:fe45:9d8c]/
> Is not taking the proxy to the netbox, so what or where is the problem?
For unrelated reasons I decided to remove gunicorn and only use the mod_wsgi module in Apache. I had issues with the PATH_INFO environment variable so I had to wrap the application function in wsgi.py. Evidently gunicorn handles it differently than mod_wsgi in Apache.
"""WSGI config for do_ipam project.It exposes the WSGI callable as a module-level variable named ``application``.For more information on this file, see"""import osimport siteimport sysfrom django.core.wsgi import get_wsgi_applicationBASE_DIR = os.path.dirname(os.path.abspath(__file__))sys.path.append(os.path.join(BASE_DIR, '..'))site.addsitedir('/usr/lib/python2.7/site-packages')os.environ["DJANGO_SETTINGS_MODULE"] = "netbox.settings"_application = get_wsgi_application()def application(environ, start_response):# Concatenate SCRIPT_NAME and PATH_INFO into PATH_INFO to force gunicorn behavior.# For some reason Django or Netbox doesn't like when mod_wsgi splits the path between themenviron['PATH_INFO'] = environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')environ['SCRIPT_NAME'] = ''return _application(environ, start_response)Here is my sanitized Apache config:
<VirtualHost *:443>ProxyPreserveHost OnServerName ipam.test.lanAlias /netbox/static /opt/netbox/netbox/static<Location /netbox>WSGIProcessGroup netbox</Location><Location /netbox/api>WSGIPassAuthorization on</Location><Directory /opt/netbox/netbox/static>Options Indexes FollowSymLinks MultiViewsAllowOverride NoneRequire all granted</Directory><Directory /opt/netbox/netbox/netbox><Files "wsgi.py">Require all granted</Files></Directory><Location /netbox/login/>AuthType KerberosAuthName "Netbox Login"KrbMethodNegotiate onKrbSaveCredentials onKrbVerifyKDC offKrbMethodK5Passwd offKrbAuthoritative offKrb5Keytab /etc/httpd/conf/keytabKrbServiceName HTTPKrbAuthRealms GDOT.AD.LOCALRequire valid-user</Location>WSGIScriptAlias /netbox /opt/netbox/netbox/netbox/wsgi.pySSLEngine onSSLCertificateFile /etc/httpd/host.crtSSLCertificateKeyFile /etc/httpd/host.key</VirtualHost>
2) it is good idea to put '*' in ALLOWED_HOSTS, as it is used to give access control. localhost and localhost6 is not the same, regardless of how it is resolved in /etc/hosts. and indeed, it is not resolved.