diff --git a/README.md b/README.md index bed7f0c..3d6e184 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,45 @@ # LegacyIP Warn -This project allows you to inject an warning banner for IPv4-users with NGINX used as a proxy. +Fork from: [https://gitlab.com/margau_me/legacyip-warn](https://gitlab.com/margau_me/legacyip-warn) + + +This project allows you to inject an warning banner for IPv4-users with NGINX webserver. It consists of two snippets and an example vhost configuration. Blog Post: [https://margau.net/posts/2020-09-06-legacyip-warn/](https://margau.net/posts/2020-09-06-legacyip-warn/) + + +# Install + +copy `legacy-banner.conf` to `/etc/nginx/snippets/legacy-banner.conf` + +copy `legacy-js.conf` to `/etc/nginx/snippets/legacy-js.conf` + +Add the script to the site config like this: + + geo $ipv4 { + 0.0.0.0/0 ipv4; + } + server { + #Listen SSL+HTTP/2 + listen 443 ssl http2; + listen [::]:443 ssl http2; + + #Server Name here + + include /etc/nginx/snippets/legacy-js.conf; + + location / { + + #normal location or proxy settings + + # IP Legacy Banner + include /etc/nginx/snippets/legacy-banner.conf; + if ($ipv4 ~ "^$") { + set $legacy ""; + } + sub_filter "script-src" "script-src 'unsafe-inline'"; + sub_filter "" $legacy; + } +} diff --git a/example-vhost.conf b/example-vhost.conf index 5c3a38c..3364210 100644 --- a/example-vhost.conf +++ b/example-vhost.conf @@ -11,10 +11,10 @@ server { include /etc/nginx/snippets/legacy-js.conf; location / { - proxy_pass (...); - include /etc/nginx/proxy_params.conf; + + #normal location or proxy settings + # IP Legacy Banner - sub_filter_types text/html; include /etc/nginx/snippets/legacy-banner.conf; if ($ipv4 ~ "^$") { set $legacy ""; diff --git a/snippets/legacy-banner.conf b/snippets/legacy-banner.conf index 104b5ab..6beb769 100644 --- a/snippets/legacy-banner.conf +++ b/snippets/legacy-banner.conf @@ -26,6 +26,6 @@ set $legacy " }
-

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte Frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
+

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close

"; diff --git a/snippets/legacy-js.conf b/snippets/legacy-js.conf index 8448e82..b555d28 100644 --- a/snippets/legacy-js.conf +++ b/snippets/legacy-js.conf @@ -6,13 +6,12 @@ function legacywarnon() { function legacywarnoff() { document.getElementById('legacywarnoverlay').style.display = 'none'; - document.cookie = 'legacywarn=true; max-age=86400 ; path=/'; + document.cookie = 'legacywarn=true; max-age=604800; path=/'; } document.addEventListener('DOMContentLoaded', function(){ document.getElementById('legacywarnoverlay').onclick = legacywarnoff; if (document.cookie.indexOf('legacywarn=') > -1) { document.getElementById('legacywarnoverlay').style.display = 'none'; - console.log('Hide Legacy IP warn'); } else { legacywarnon(); }