This let you configure an easy gdpr wall on your vhost.
In apache2 we can use RewriteEngine
1 to rewrite requested URLs on the fly.
We redirect all requested URLs to a subpath "/gdpr" if the user has not consented to our gdpr_cookie
.
If the user requested a URL with subpath like https://example.com/some/path/index.html
we save
the subpath for subsequent redirects.
- Copy the files in
src/
to/var/www/gdpr
or/var/www/gdpr/perVhostGdpr
. - Copy the files in
config/
to/etc/apache2/
.
You have to define the GDPR_COOKIE_NAME
variable in your vhost like:
Define GDPR_COOKIE_NAME gdpr_approved
If your files located at /var/www/gdpr/perVhostGdpr
or something you have to redefine the
location in gdpr.conf
:
Alias /gdpr /var/www/gdpr -> Alias /gdpr /var/www/gdpr/perVhostGdpr
You have to change some variables in files/gdpr.js
:
const gdpr_cookie = "gdpr_approved";
const cookie_max_age = "7776000"; // 90 days
const domain = "example.com";
Here is a snippet for an example vhost
<--- snip --->
Define GDPR_COOKIE_NAME gdpr_approved
<--- snip --->
DocumentRoot /var/www/empty
# restrict accessibility
<Location />
Require all denied
</Location>
########### GDPR WALL #################
Include gdpr.conf
########### GDPR WALL #################
Alias /website /var/www/html/htdocs/website
<Location /website>
Require all granted
Options +MultiViews
</Location>
<--- snip --->
</VirtualHost>
</IfModule>
Don't forget to change the GDPR-text in the index.html
file :)
- The Brave browsers shields function 2 blocks the
gdpr.js
javasrcipt. You have to disable it for your site.
Thanks to senfcall 3 for the inspirations.