dimanche 31 mai 2020

Restrict access on webpage using .htaccess

Hey I am currently running into the problem, that I want to restrict access on some websites in my html root folder, so I can access them only from my local Network.

The Problem is, that neither the site.conf file works nor the .htaccess file in the root folder of the specific website.

My 000-default.conf looks like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /home/username/htmlfolder
        <Directory />
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
        DocumentRoot /home/username/htmlfolder
        ServerName myurl.com
        <Directory />
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"

        SSLEngine on
        SSLCertificateFile /linktomy.crt
        SSLCertificateKeyFile /linktomy.key
</VirtualHost>

and my .htaccess file looks like this:

Require ip 192.168.0.0/255.255.255.0
ErrorDocument 403 "Access Restricted!"

The Problem is, that a syntax error in the .htaccess file is making no error when restarting the apache2 server using sudo service apache2 restart and I can still access those websites from a different IP. Using the 2 parameters from the .htaccess file in the 000-default.conf file instead of Require all granted is also not doing anything.

How can I resolve this?




Aucun commentaire:

Enregistrer un commentaire