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

Latest articles

WordPress jobs running late? Learn how to separate scheduling problems, task errors and a growing backlog, then choose the right scheduler or runner.

Before changing an AI workflow, check that it still does the job. Use realistic examples, clear release criteria and a comparison with the version running today.

Sending an invoice does not mean it has arrived. Understand delivery statuses, the system requirements coming in 2027, and how focused AI support can help finance teams handle errors and follow-up.

Before scaling AI content, check the pages you already have. Verify claims, resolve overlapping coverage, and give WordPress reviewers control over publication.

Build a refund approval workflow in n8n and Stripe that shows reviewers the exact action, expires old approvals and tracks refunds through to completion.

A timeout can hide a successful job creation. Use stable operation IDs, destination API rules and a clear recovery process to prevent duplicate work.

Does your ChatGPT subscription cover website translation? Understand API credits, access and a WordPress workflow that turns approved Danish content into translation drafts.

An internal AI can keep quoting a deleted policy. Check document updates, indexed passages and cached answers to find where outdated guidance survives.

Codex drew all ten pages of my Ninjai comic from the script Claude wrote in the first test. What made that handover work, and what it cost.

ChatGPT delivered ten painted comic pages; Claude drew one page in code. A practical look at AI tool selection, creative briefs and approval decisions.