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