How can we help?

Redirect port HTTP:80 to HTTPS:443

Follow

If you want do disable HTTP access, we suggest to redirect traffic from port 80 to HTTPS port 443. It can be achieved by editing few configuration files:

NXS Rev1:

Edit file:
nano /etc/apache2/sites-enabled/000-default
At the end of the file, before end of Virtual Host add:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]


In our device it looks like that:

CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]


Save and exit with CTRL+X,y

Then you have to enable module with command:
a2enmod rewrite
and restart Apache webserver
service apache2 restart

After that changes every request for port 80 (HTTP) will be redirected to HTTPS (port 443).

=====================================================================================================

NXS Rev2:

Please edit file:
/etc/apache2/sites-enabled/000-default.conf

and uncomment lines:
#RewriteEngine on
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]

(by uncomment I mean delete # signs at start of these lines)

Save and exit with CTRL+X,y

Then you have to enable rewrite module with command in case it's not enabled already:
a2enmod rewrite

Restart Apache engine:
systemctl restart apache2

After that changes every request for port 80 (HTTP) will be redirected to HTTPS (port 443).

NPE line:

Please edit file:
/mnt/nand-user/lighttpd/etc/lighttpd.conf

Add section:

$HTTP["scheme"] == "http" {
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
    }
}

Then just restart webserver:
killall lighttpd
/mnt/nand-user/lighttpd/setup-autostart.sh

Was this article helpful?
0 out of 0 found this helpful