Guides / Cloudflare + IPv6
Your own ports 80 and 443 with IPv6 and Cloudflare
Last updated 2 December 2026 · By Mohammad AlSaraf
On IPv4 your server shares an address with others, so ports 80 and 443 reach you by name, through the domains you link on the Domains tab. On IPv6 it's different: your server has its own block of addresses, and every port on them is yours. The catch is that many visitors still only have IPv4.
Cloudflare's free proxy closes that gap. You point a proxied AAAA record at your server's IPv6 address. Visitors connect to Cloudflare over IPv4 or IPv6, and Cloudflare connects to your server over IPv6. You get:
- your own ports 80 and 443 (and a few others, see below), with nothing to link on our side;
- no limit on the number of domains, because nothing counts against your plan's domain limit;
- a real certificate and your visitors' real IP addresses in your logs;
- your server's address hidden behind Cloudflare.
Everything below was tested on a natbox server on 2 December 2026, with a temporary test name. Replace app.example.com with your own name and 2a02:c207:…:N::1 with your server's address.
1. Find your IPv6 address
Your server's IPv6 block is shown on its page in the client area, for example 2a02:c207:…:N::/80. Its first address, ending in ::1, is already set up on your server. On the server:
ip -br -6 addr show eth0
Use the address that ends in ::1/80, without the /80. Check that your web server answers on it from outside, for example from your own computer if it has IPv6:
curl -6 -I http://[2a02:c207:…:N::1]/
2. Add a proxied AAAA record
In Cloudflare, open your domain, go to DNS → Records and add:
| Type | Name | IPv6 address | Proxy status |
|---|---|---|---|
| AAAA | app | 2a02:c207:…:N::1 | Proxied (orange cloud) |
Add only the AAAA record. Don't add an A record for this name: your server has no IPv4 address of its own, and Cloudflare gives IPv4 visitors its own addresses anyway. The orange cloud is what makes it work for IPv4 visitors. With a grey cloud (DNS only), only visitors who have IPv6 could reach you.
Within a minute, the name answers on IPv4 too. In our test, an IPv4-only request got the page from the server's IPv6 address:
$ curl -4 -s http://app.example.com/
<h1>Hello from my natbox server over IPv6</h1>
3. HTTPS
Set Cloudflare to check your server's certificate: SSL/TLS → Overview → Full (strict). Then give your server a real certificate. Let's Encrypt works through Cloudflare's proxy, because the HTTP check on port 80 reaches your server like any other visitor:
apt install -y nginx certbot python3-certbot-nginx
certbot --nginx -d app.example.com
Your nginx server block needs server_name app.example.com; and listen [::]:80; first, so certbot finds it. Until the certificate is there, Cloudflare shows error 521 or 526 for HTTPS. That is expected. Renewal works the same way: certbot renew --dry-run checks it.
Another option is a free Cloudflare Origin Certificate (SSL/TLS → Origin Server), valid for up to 15 years. Only Cloudflare trusts it, so use it only when every visitor comes through the orange cloud.
4. See your visitors' real IP addresses
Behind the proxy, your logs show Cloudflare's addresses (2400:cb00:…) instead of your visitors'. Cloudflare sends the real one in a header. Tell nginx to trust it, but only from Cloudflare's addresses:
{
echo "# Cloudflare's addresses, from https://www.cloudflare.com/ips"
for list in ips-v6 ips-v4; do curl -s "https://www.cloudflare.com/$list"; echo; done | grep . | sed 's/.*/set_real_ip_from &;/'
echo "real_ip_header CF-Connecting-IP;"
} > /etc/nginx/conf.d/cloudflare-real-ip.conf
nginx -t && systemctl reload nginx
The echo after each download matters: Cloudflare's lists don't end with a new line, and without it two addresses run together and nginx refuses the file. Cloudflare rarely changes these lists; run the block again now and then to refresh them.
5. Only let Cloudflare in on ports 80 and 443
Your IPv6 address is still reachable directly, which skips Cloudflare's protection. This nftables table drops web traffic over IPv6 that doesn't come from Cloudflare, and leaves everything else alone (SSH, your other ports, IPv4):
apt install -y nftables
{
echo "table inet cloudflare_only"
echo "delete table inet cloudflare_only"
echo "table inet cloudflare_only {"
echo " set cf6 { type ipv6_addr; flags interval; elements = {"
curl -s https://www.cloudflare.com/ips-v6; echo
echo " } }"
echo " chain input {"
echo " type filter hook input priority -1; policy accept;"
echo " tcp dport { 80, 443 } ip6 saddr != @cf6 drop"
echo " }"
echo "}"
} | sed '/elements = {/,/} }/{/^[0-9a-f]/s/$/,/}' > /etc/nftables-cloudflare.conf
nft -c -f /etc/nftables-cloudflare.conf && nft -f /etc/nftables-cloudflare.conf
If you also use another Cloudflare port, such as 8443, add it to { 80, 443 } in the file.
To load it again after a restart, /etc/nftables.conf must include it. If that file is still Ubuntu's default (it starts with flush ruleset and has only empty chains), replace it with these two lines. If it holds the table from Firewall your IPv6, add only the include line at its end.
#!/usr/sbin/nft -f
include "/etc/nftables-cloudflare.conf"
nft -c -f /etc/nftables.conf && systemctl enable nftables
Don't keep flush ruleset in that file: it deletes every firewall and NAT rule on your server when nftables loads, including the ones your WireGuard VPN needs. We restarted the test server after this step: the table came back and the site kept working.
Our test after loading it:
direct to the IPv6 address, port 443: no answer (dropped)
direct to the IPv6 address, port 22: open
through Cloudflare over IPv4: 200
through Cloudflare over IPv6: 200
Which ports work
Cloudflare's free proxy only passes web traffic, on these ports:
| HTTP | 80, 8080, 8880, 2052, 2082, 2086, 2095 |
|---|---|
| HTTPS | 443, 2053, 2083, 2087, 2096, 8443 |
So a second app can run on https://app.example.com:8443, which we tested. Other ports, such as 3000, don't pass through: put those apps behind nginx on 443 with proxy_pass (see nginx reverse proxy). Game servers, VPNs, SSH and anything that isn't HTTP don't go through Cloudflare's free proxy at all; for those, use your forwarded IPv4 ports, or your IPv6 address directly.
Good to know
- Works on every plan, the free trial included, because every server has its own IPv6 block.
- WebSockets work through the proxy. On Cloudflare's free plan, uploads are limited to 100 MB per request, and a request that takes longer than 100 seconds is cut off.
- You can mix both ways: some names linked on the Domains tab over our shared IPv4, others through Cloudflare over IPv6.
- Cloudflare decrypts HTTPS at its edge to proxy it. If you need end-to-end encryption that nobody in between can read, link the domain on the Domains tab instead: on our shared IPv4, HTTPS passes through still encrypted.
Recommended plan: Box for most small sites and APIs.
More guides: Run apps on your NAT VPS ports, Host a Discord bot 24/7, Stop SSH brute-force attacks with fail2ban.