Cloudflare SSL on a VPS: A Practical Setup Without the Gotchas

Illustrated infographic summarizing: Cloudflare SSL on a VPS: A Practical Setup Without the Gotchas

By Greg Nowak. Updated 19 November 2026.

A website can work over HTTPS while its VPS setup remains fragile. The browser sees Cloudflare’s certificate, but that tells you little about certificate renewal on the server, direct access or what happens when someone disables the proxy during an incident.

For a business owner, operations lead or agency team, the goal is straightforward: keep the website working through routine changes and leave the next person enough information to maintain it. Start with the recovery plan, then configure the certificates, redirects and access rules to support it.

Choose the certificate around your fallback plan

Cloudflare creates two connections: visitor to Cloudflare, and Cloudflare to your VPS. Each has its own TLS configuration. Before installing an origin certificate, decide whether visitors or services must ever connect directly to the VPS using your domain.

Your requirement Certificate choice Operational consequence
All website traffic stays behind Cloudflare Cloudflare Origin CA can fit Track its expiry and arrange replacement.
Browsers must work with proxying disabled Publicly trusted certificate Prepare firewall and authentication changes for that route too.
A monitor or partner connects directly Usually a publicly trusted certificate Permit that access deliberately and test hostname validation.
Public requests must always pass through Cloudflare Either certificate type Enforce origin access restrictions separately.
Choose the certificate for the connections you intend to support, including incident recovery.

Cloudflare Origin CA certificates work for the Cloudflare-to-origin connection, but ordinary browsers do not trust them. Disabling proxying can therefore produce certificate warnings. Cloudflare currently sends no expiry notifications for these certificates; give replacement a named owner and an independent alert.

Prepare the VPS before enabling Full (strict)

Use Full (strict) once the origin is ready. It checks that the origin certificate is unexpired, matches the requested or target hostname, and comes from a publicly trusted authority or Cloudflare Origin CA. The VPS must accept HTTPS on port 443. An invalid origin certificate can cause a 526 error.

Check every origin affected by a zone-wide setting. Replacing Flexible mode also needs care: it uses HTTP to the origin and can loop when that origin redirects requests back to HTTPS.

Inventory the apex domain, www and other required hostnames. Confirm their DNS destinations and proxy status. Back up the working application configuration before changing it.

For a manually installed Origin CA certificate, merge these directives into the existing NGINX application server block, following the NGINX HTTPS guidance:

server {
    listen 443 ssl;
    server_name example.com www.example.com;

    ssl_certificate     /etc/ssl/cloudflare/origin.pem;
    ssl_certificate_key /etc/ssl/private/cloudflare-origin.key;

    # Keep the application's existing routing directives here.
}

Replace the names and paths. Keep the private key outside the web root with restricted permissions that still allow NGINX to read it. Public certificates need the appropriate intermediate chain in the certificate file.

sudo nginx -t
sudo systemctl reload nginx

Run the reload only after validation succeeds. On a system using another service manager, use its equivalent. Test the origin with the correct hostname and certificate trust configuration before switching Cloudflare to Full (strict).

Make renewal prove more than issuance

For a public certificate, install a supported ACME client for your operating system. With Certbot and its NGINX plugin installed, obtain and install the certificate using:

sudo certbot --nginx
sudo certbot renew --dry-run

The first command can edit NGINX configuration; review those changes. The Certbot user guide covers renewal scheduling and deployment hooks. Confirm the renewal timer or cron job exists and check how the renewed certificate reaches NGINX.

A dry run tests renewal but does not run deployment hooks by default. If you use a custom deployment hook, review its effects before testing with --run-deploy-hooks. Verify the certificate actually served after deployment.

The NGINX plugin uses HTTP-01 validation on public port 80. Ensure challenge requests reach it through Cloudflare and your access rules. For wildcard certificates or an origin without public web access, use automated DNS-01 validation with narrowly scoped DNS credentials. Manual TXT-record updates need additional automation for unattended renewal.

Test the visitor journey and the origin separately

Agree where HTTP becomes HTTPS and where the canonical hostname is selected. Cloudflare, NGINX and the application may each contain redirects. Review their combined behaviour before adding another rule.

Check HTTP and HTTPS on both the apex and www hostnames. Each should reach the intended destination without loops, preserving paths and query strings. Then test login, forms, checkout where applicable, API calls and callbacks. Check templates and stored content for HTTP asset URLs.

A public HTTPS check normally sees Cloudflare’s certificate. Add an origin-specific check for expiry and hostname validity, using the appropriate trusted CA. If direct access is an agreed fallback, test that route too.

Control who can reach the VPS

Full (strict) validates the server; it does not block requests that bypass Cloudflare. For a publicly reachable origin, consider restricting web ports to Cloudflare’s current IP ranges and maintaining that allowlist.

Authenticated Origin Pulls adds client-certificate authentication. The global certificate proves a request comes from Cloudflare’s network. Use your own zone-level or per-hostname certificate when you need account-specific separation. AOP does not apply to Cloudflare Tunnel connections.

Inventory monitoring and vendor connections before enforcing restrictions. Preserve administrative access, test that unwanted direct requests fail, and document any changes needed for recovery.

Hand over a setup someone can operate

Record the hostnames, encryption mode, certificate paths, expiry, renewal mechanism, redirect rules and origin restrictions. Include rollback steps, alert destinations and who owns each task. Keep private keys and API tokens in your team’s secrets system.

Walk through a renewal check and a recovery scenario together. For an agency handover, this exposes missing access and unclear responsibilities while everyone is available to fix them.

If your setup has accumulated rules across migrations or suppliers, Greg can help review the request path, renewal process and recovery options. Ask Greg about a Cloudflare and VPS review, with a practical handover your team can use.

Related on GrN.dk

Need help with this kind of work?

Ask Greg about a Cloudflare and VPS review Get in touch with Greg.

Sources

Seneste artikler

En sendt faktura er ikke nødvendigvis nået frem. Få styr på leveringsstatus, systemkravene i 2027 og afgrænset AI-hjælp til fejl og opfølgning i økonomiafdelingen.

Rækker jeres ChatGPT-licens til weboversættelser? Få overblik over API-kreditter, adgang og en WordPress-proces fra godkendt dansk tekst til oversættelseskladder.

Få styr på manglende bilag med et afgrænset AI-flow, der sorterer svar, koordinerer påmindelser og giver bogholderen en overskuelig liste til opfølgning.

Lad AI skrive kampagneudkast til Black Friday ud fra godkendte produktdata. Få styr på priser, modtagere og godkendelse, før Mailchimp-kladden bliver sendt.

Få tilbudsmails fra Outlook ind i CRM med AI. Afklar felter, dubletter og sælgeransvar, og mål i en pilot, om løsningen sparer tid og får flere forespørgsler fulgt op.

Gør månedsrapporten lettere at gentage med AI til Excel, Python og faste kontroller. Få styr på import, fejllister og afstemning, så tallene kan efterprøves.

Få godkendte timer fra Clockify med på fakturakladder i Dinero. AI skriver ydelsesbeskrivelser, mens faste regler styrer beløb, godkendelse og genkørsler.

Lad AI kundeservice hente ordrestatus fra Shopify og Shipmondo. Se, hvordan I afgrænser opgaven, kontrollerer kundens identitet og sender usikre sager videre.

Når kunden beder om indsigt, kan AI hjælpe med at samle materiale fra WordPress og Microsoft 365. Se, hvordan I holder styr på datakilder, ansvar og kontrol.

Når en ingrediens ændres, kan menukortet kræve rettelser, selv om opskriftsdatoen står stille. Sådan kan AI hjælpe med gennemgang og godkendelse i WordPress.