Project

General

Profile

How to disable IPv4 on your website » History » Version 7

Nico Schottelius, 02/05/2019 03:43 PM

1 1 Nico Schottelius
h1. How to disable IPv4 on your website
2
3
{{toc}}
4
5
h2. Status
6
7 4 Nico Schottelius
This document is *IN PRODUCTION*.
8 1 Nico Schottelius
9
h2. Introduction
10
11
This article is for you, if you want to only allow IPv6 traffic to
12
your website or some parts of your website. This article is also for
13
you if you are running a website on an IPv6 only webserver / VM.
14
15 3 Nico Schottelius
h2. TL;DR
16
17
* For IPv6 only servers add an DNS A entry to 185.203.114.115.
18
* For Dual stack servers redirect to to https://no-ipv4-here.ungleich.ch/?back_to=https://your-page-here/your-path
19
20 1 Nico Schottelius
h2. IPv6 only webservers
21
22
If you are running an IPv6 only webserver, IPv4 clients cannot reach
23
you. They will be presented with an error message from the
24
browser.
25
26
This is clearly not an expected behaviour and your visitors will
27
likely be confused.
28
29
To solve this problem, you can add a DNS "A" entry for your website
30
pointing to 185.203.114.115. IPv4 only visitors will then be presented
31
with the content of https://no-ipv4-here.ungleich.ch/ that explains to
32
them that they need IPv6 to visit your website.
33
34
h3. Summary
35
36
If you want to help IPv4 visitors to visit IPv6 only websites, you can
37
add a DNS A entry pointing to 185.203.114.115. Below is the example
38
code for the BIND DNS server:
39
40
<pre>
41
; The first one should already be present
42
example.com. IN AAAA your:ipv6:address::
43
44
; This one allows visitors to get a hint
45
example.com. IN A 185.203.114.115
46
</pre>
47
48 2 Nico Schottelius
h2. Dual Stack Webserver: Disabling IPv4 traffic on (parts of) your website
49 1 Nico Schottelius
50
If you are running a Dual Stack website (reachable by IPv6 and IPv4)
51
and you want to disable IPv4 traffic, you can redirect the user to
52 2 Nico Schottelius
http://no-ipv4-here.ungleich.ch?back_to=https://www.example.com/your-url
53 1 Nico Schottelius
54
h3. Sample nginx configuration for disabling IPv4 traffic
55
56
Assuming that you want to disable 
57
<pre>
58
geo $iptype {
59
    0.0.0.0/0 ipv4;
60
}
61
62
63
server {
64
    ...
65
    location ~* ^/ipv6/work/(login|logout|signup|jobs)/(.*)$ {
66
       if ($iptype) {
67
           return 302 https://no-ipv4-here.ungleich.ch/?back_to=$scheme://$host$uri;
68
       }
69
       proxy_pass https://www-server.ipv6.work/$1/$2;
70
    }
71
    ...
72
}
73
74 5 Nico Schottelius
</pre>
75
76 7 Nico Schottelius
Checkout our "blog entry about nginx/geo detection":https://ungleich.ch/en-us/cms/blog/2019/01/27/how-to-distinguish-ipv6-and-ipv4-traffic-with-nginx/ for more information about the nginx configuration.
77 3 Nico Schottelius
78
h3. Changing / Modifying no-ipv4-here.ungleich.ch
79
80
If you want to make changes to the website, you can access the source code of it on https://code.ungleich.ch/ungleich-public/ungleich-no-ipv4-here and submit changes to it.