legacyip-warn/README.md

48 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2020-09-06 19:41:17 +02:00
# LegacyIP Warn
2022-03-30 14:35:26 +02:00
Fork from: [https://gitlab.com/margau_me/legacyip-warn](https://gitlab.com/margau_me/legacyip-warn)
2022-03-30 14:38:02 +02:00
This project allows you to inject an warning banner for IPv4-users with a NGINX webserver.
2020-09-06 20:03:40 +02:00
It consists of two snippets and an example vhost configuration.
2020-09-06 21:51:30 +02:00
Blog Post: [https://margau.net/posts/2020-09-06-legacyip-warn/](https://margau.net/posts/2020-09-06-legacyip-warn/)
2022-03-30 14:35:26 +02:00
# Install
2022-08-17 11:06:10 +02:00
`mkdir /etc/nginx/snippets`
2022-03-30 14:35:26 +02:00
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 "<!-- uses IPv6 --></body>";
}
2022-08-17 11:06:10 +02:00
sub_filter "script-src 'unsafe-inline' 'unsafe-inline'" "script-src 'unsafe-inline'";
2022-03-30 14:35:26 +02:00
sub_filter "</body>" $legacy;
2022-03-30 14:38:02 +02:00
}
}