Add HTTP redirect to reference Apache configuration #7588

Closed
opened 2025-12-29 20:25:49 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Feb 1, 2023).

Originally assigned to: @rganascim on GitHub.

Change Type

Addition

Area

Installation/upgrade

Proposed Changes

Extend the reference Apache server configuration that ships with NetBox to include a rule that redirects all HTTP requests to HTTPS. (This is already included in the nginx config.)

Originally created by @jeremystretch on GitHub (Feb 1, 2023). Originally assigned to: @rganascim on GitHub. ### Change Type Addition ### Area Installation/upgrade ### Proposed Changes Extend the [reference Apache server configuration](https://github.com/netbox-community/netbox/blob/develop/contrib/apache.conf) that ships with NetBox to include a rule that redirects all HTTP requests to HTTPS. (This is already included in the nginx config.)
adam added the status: acceptedtype: documentation labels 2025-12-29 20:25:49 +01:00
adam closed this issue 2025-12-29 20:25:49 +01:00
Author
Owner

@rganascim commented on GitHub (Feb 19, 2023):

I can add this configuration if you allow it.

Configuration sequence:

  • add the virtualhost for the port 80 in the netbox file (redirect using the mod_rewrite way)
  • disable the default web site: sudo a2dissite 000-default
  • enable mod_rewrite: sudo a2enmod rewrite
  • restart apache2: sudo systemctl restart apache2

Add to apache2.conf netbox template:

<VirtualHost *:80>
   ServerName netbox.same.as.443.port
   RewriteEngine On
   RewriteCond %{HTTPS} !=on
   RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>

@rganascim commented on GitHub (Feb 19, 2023): I can add this configuration if you allow it. Configuration sequence: - add the virtualhost for the port 80 in the netbox file (redirect using the mod_rewrite way) - disable the default web site: sudo a2dissite 000-default - enable mod_rewrite: sudo a2enmod rewrite - restart apache2: sudo systemctl restart apache2 Add to apache2.conf netbox template: ``` <VirtualHost *:80> ServerName netbox.same.as.443.port RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] </VirtualHost> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7588