Step-by-Step Instructions for Setting up NetBox with Apache and SSL on CentOS 7 #488

Closed
opened 2025-12-29 16:22:35 +01:00 by adam · 1 comment
Owner

Originally created by @darthcrypto on GitHub (Oct 25, 2016).

  1. ./manage.py runserver 0.0.0.0:8000 --insecure

  2. yum install mod_ssl

  3. request SSL cert and key from respective CA

  4. create file /etc/httpd/conf.d/netbox.conf and add the following:

LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so
Listen 443

SSLPassPhraseDialog  builtin

SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300

SSLCryptoDevice builtin

<VirtualHost *:80>
    ProxyPreserveHost On

    ServerName netbox.yourdomain

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L]

    Alias /project-static /var/www/html/netbox/netbox/project-static

    <Directory /var/www/html/netbox/netbox/project-static>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    <Location /project-static>
        ProxyPass !
    </Location>

    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost>


<VirtualHost *:443>
    ProxyPreserveHost On

    ServerName netbox.yourdomain

    ErrorLog /var/log/httpd/ssl_error_log
    TransferLog /var/log/httpd/ssl_access_log
    LogLevel warn

    SSLEngine on
    SSLProtocol All -SSLv2 -SSLv3
    SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:AES256+RSA
    SSLHonorCipherOrder on
    SSLCertificateKeyFile /location/of/your/certificate/keyfile
    SSLCertificateFile /location/of/your/certificate/file
    SSLCACertificateFile /location/of/your/CAcertfile

    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    SetEnvIf User-Agent ".*MSIE.*" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0
    CustomLog logs/ssl_request_log \
    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

    Alias /project-static /var/www/html/netbox/netbox/project-static

    <Directory /var/www/html/netbox/netbox/project-static>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    <Location /project-static>
        ProxyPass !
    </Location>

    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/
  1. systemctl restart httpd

  2. go to netbox.yourdomain in a web browser and it will automatically be forwarded to https site

Originally created by @darthcrypto on GitHub (Oct 25, 2016). 1) ./manage.py runserver 0.0.0.0:8000 --insecure 2) yum install mod_ssl 3) request SSL cert and key from respective CA 4) create file /etc/httpd/conf.d/netbox.conf and add the following: ``` LoadModule ssl_module /usr/lib64/httpd/modules/mod_ssl.so Listen 443 SSLPassPhraseDialog builtin SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000) SSLSessionCacheTimeout 300 SSLCryptoDevice builtin <VirtualHost *:80> ProxyPreserveHost On ServerName netbox.yourdomain RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L] Alias /project-static /var/www/html/netbox/netbox/project-static <Directory /var/www/html/netbox/netbox/project-static> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> <Location /project-static> ProxyPass ! </Location> ProxyPass / http://127.0.0.1:8000/ ProxyPassReverse / http://127.0.0.1:8000/ </VirtualHost> <VirtualHost *:443> ProxyPreserveHost On ServerName netbox.yourdomain ErrorLog /var/log/httpd/ssl_error_log TransferLog /var/log/httpd/ssl_access_log LogLevel warn SSLEngine on SSLProtocol All -SSLv2 -SSLv3 SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:AES256+RSA SSLHonorCipherOrder on SSLCertificateKeyFile /location/of/your/certificate/keyfile SSLCertificateFile /location/of/your/certificate/file SSLCACertificateFile /location/of/your/CAcertfile <Files ~ "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> SetEnvIf User-Agent ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog logs/ssl_request_log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" Alias /project-static /var/www/html/netbox/netbox/project-static <Directory /var/www/html/netbox/netbox/project-static> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> <Location /project-static> ProxyPass ! </Location> ProxyPass / http://127.0.0.1:8000/ ProxyPassReverse / http://127.0.0.1:8000/ ``` 5) systemctl restart httpd 6) go to netbox.yourdomain in a web browser and it will automatically be forwarded to https site
adam closed this issue 2025-12-29 16:22:36 +01:00
Author
Owner

@oletos7j commented on GitHub (May 29, 2017):

There is an extra character in line 18, the % sign can be removed.

Also, the newest Netbox documentation shows to use /project instead of /project-static for the Alias and Directory. The rest of your file helped me out, especially with the redirect. Thanks!

@oletos7j commented on GitHub (May 29, 2017): There is an extra character in line 18, the % sign can be removed. Also, the newest Netbox documentation shows to use /project instead of /project-static for the Alias and Directory. The rest of your file helped me out, especially with the redirect. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#488