netbox in subfolder (httpd configuration)

1,349 views
Skip to first unread message

Sergey Kharlamov

unread,
Nov 17, 2017, 3:48:25 PM11/17/17
to NetBox
Hi All,
I'm trying to install netbox to the same machine where I have centreon monitoring tool (CentOS 7).
I need to be able to use 2 subfolders: /centreon and /netbox.
I was trying to play with a configs but no luck. I can't use dns or virtual hosts... Can you please share you knowledge how to setup it properly? 
this products should be accessible by

Please help me to resolve this issue.
Thanks
Serge

Brian Candler

unread,
Nov 17, 2017, 4:45:47 PM11/17/17
to NetBox
On Friday, 17 November 2017 20:48:25 UTC, Sergey Kharlamov wrote:

I need to be able to use 2 subfolders: /centreon and /netbox.
I was trying to play with a configs but no luck.

What did you try?  Have you set BASE_PATH in configuration.py (described in configuration.example.py)?  See also
 
I can't use dns or virtual hosts...

You can try using BASE_PATH as per the link above, and then configuring your existing webserver which is serving /centreon to proxy /netbox to gunicorn.

However I'm afraid you'll be pretty much on your own (especially as you haven't described anything at all about the existing webserver configuration).

If you want an easy life and something which is simple to manage, create a new virtual machine on a different IP address and use that for netbox.

Josh Miller

unread,
Nov 18, 2017, 2:35:31 AM11/18/17
to NetBox
In addition to Brian's suggestion of changing the BASE_PATH variable in configuration.py, appending the following to the settings.py file worked well for me.

#Set main application URL on admin site and set path for cookies.
from django.contrib import admin
admin
.site.site_url = LANGUAGE_COOKIE_PATH = SESSION_COOKIE_PATH = CSRF_COOKIE_PATH = '/' + BASE_PATH

For my use case I needed two independent instances of Netbox running on the same domain name (e.g. https://example.com/external-netbox/https://example.com/internal-netbox/). I had issues with the session and CSRF cookies overwriting the other instance's cookies, so one could only be logged into one or the other. I imagine someone attempting to host more than one Django application on the same domain could have a similar problem.
Message has been deleted

Sergey Kharlamov

unread,
Nov 20, 2017, 10:05:22 AM11/20/17
to NetBox
Here is my netbox.conf for apache configuration

<VirtualHost *:80>
    ProxyPreserveHost On

    ServerName mon.example.com

    Alias /netbox/static /opt/netbox/netbox/static

   # Alias /netbox /opt/netbox


    # Needed to allow token-based API authentication
    WSGIPassAuthorization on

    <Directory /opt/netbox/netbox/static>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Require all granted
    </Directory>

    <Location /netbox/static>
        ProxyPass !
    </Location>

    ProxyPass /netbox http://127.0.0.1:8001/
    ProxyPassReverse /netbox http://127.0.0.1:8001/


</VirtualHost>

I also set BASE_PATH = 'netbox/'

I enable debug and when I go to xx.xx.xx.xx/netbox it show me that page not found 404

Using the URLconf defined in netbox.urls, Django tried these URL patterns, in this order:

  1. ^netbox/

The empty path didn't match any of these.

Jacob Mansfield

unread,
Nov 20, 2017, 10:13:39 AM11/20/17
to Sergey Kharlamov, NetBox
Your ProxyPass and ProxyPassReverse in the Apache config will need to reference http://127.0.0.1:8001/netbox/

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to netbox-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/725d29b6-2d68-48bc-8de8-ece1690af9d9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sergey Kharlamov

unread,
Nov 20, 2017, 10:23:26 AM11/20/17
to NetBox
YEAAAAAA!

Thank you sooo much! =)

Final config will be:

<VirtualHost *:80>
    ProxyPreserveHost On

    ServerName mon.example.com

    Alias /netbox/static /opt/netbox/netbox/static

    # Needed to allow token-based API authentication
    WSGIPassAuthorization on

    <Directory /opt/netbox/netbox/static>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Require all granted
    </Directory>

    <Location /netbox/static>
        ProxyPass !
    </Location>

    ProxyPass /netbox http://127.0.0.1:8001/netbox
    ProxyPassReverse /netbox http://127.0.0.1:8001/netbox


</VirtualHost>

Work great!

To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages