Guide
Hide your VPS behind Cloudflare
Anyone who knows the IP address of your server can flood it directly. Behind the Cloudflare proxy, visitors only ever see Cloudflare, and attacks on your website land on Cloudflare instead of on you.
Updated 17 November 2026
This works for websites and web apps: anything that answers on ports 80 and 443. It takes about twenty minutes on Debian or Ubuntu, and the free Cloudflare plan is enough.
Why it matters
A flood aimed at one address fills the line in front of the server, and every site on it goes quiet. DDoS protection is included in Romania and the Netherlands, but the best attack is the one that never finds your address. With the proxy in front, the address in DNS is Cloudflare's, and yours stays private.
What you need
- A VPS with your website on it, and root access over SSH.
- A domain, registered with us or anywhere else.
- A free Cloudflare account.
Step 1: move the domain's DNS to Cloudflare
Add the domain in Cloudflare and let it read your records. It gives you two nameservers. Set them at your registrar; for a domain registered with us, that is under Domains in the client area. It usually takes less than an hour.
Step 2: turn the proxy on
In Cloudflare's DNS page, the A record for your site points at your VPS. Make sure the cloud next to it is orange, which means Proxied. Do the same for www. A grey cloud means DNS only, and then the world sees your address.
Step 3: encrypt the line between Cloudflare and your server
Under SSL/TLS, Origin Server, create an Origin Certificate for your domain and put the certificate and key on the server. Point your web server at them, then set the SSL mode to Full (strict). Visitors get Cloudflare's certificate, and the hop to your VPS is encrypted too.
# nginx, inside the server block of your site
ssl_certificate /etc/ssl/origin.pem;
ssl_certificate_key /etc/ssl/origin.key;Step 4: let only Cloudflare reach the website
Cloudflare publishes the addresses it connects from. Allow ports 80 and 443 from those and nothing else, so a scan of your address finds no website at all. Keep SSH open for yourself.
ufw default deny incoming
ufw allow 22/tcp
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
ufw allow proto tcp from $ip to any port 80,443
done
ufw enableThe list changes now and then. Run the loop again once a month, or put it in cron.
Step 5: see your real visitors in the logs
Behind the proxy every request seems to come from Cloudflare. Tell nginx to read the visitor's address from Cloudflare's header instead:
curl -s https://www.cloudflare.com/ips-v4 | sed 's/^/set_real_ip_from /; s/$/;/' > /etc/nginx/conf.d/cloudflare.conf
echo 'real_ip_header CF-Connecting-IP;' >> /etc/nginx/conf.d/cloudflare.conf
nginx -t && systemctl reload nginxStep 6: do not leak the address
- Mail sent from the web server carries its address in the headers. Send through another server or a mail service.
- Records such as mail, ftp or direct with a grey cloud on the same address give it away. Remove them or move them.
- If the site ran without the proxy before, old DNS records are kept by public history services. Move the site to a new address after you switch.
- Links or scripts in your pages that use the IP address directly show it to every visitor.
An extra IPv4 address on any of our VPS plans costs $2 a month, so moving to a fresh one is cheap.
What Cloudflare does not cover
On the free plan the proxy carries only web traffic. SSH, mail, game servers and VPN connections still go straight to your address. Cloudflare has rules of its own, and it passes complaints about a site on to the host, so our acceptable use policy still applies.
FAQ
Questions
Does Cloudflare hide my server completely?
It hides the address for web traffic going through the proxy. If the address leaked before, through old DNS records, mail headers or a grey cloud record, someone can still find it. Move to a fresh address after you switch.
Can I use Cloudflare with a Nyra Host VPS?
Yes. Nothing on our side blocks it, and it works the same in every location.
Do I need Cloudflare for an onion site?
No. An onion site is reached through Tor and never shows the address of the server, so there is nothing to hide.
The details are in our acceptable use policy and our refund policy.
More guides
Read next
Servers from $14 a month
Email signup, crypto payment and full root access.