Skip to main content
GrN.dk

Main navigation

  • Articles
  • Cases
  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Join my community / free newsletter — sign up here

Breadcrumb

  1. Home

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

By Greg Nowak. Updated 1 August 2026.

Putting a VPS behind Cloudflare creates two encrypted connections, not one: the visitor connects to Cloudflare, then Cloudflare connects to your origin server. A browser padlock confirms the first connection. It does not prove that the VPS has the right certificate, cannot be reached around Cloudflare, or will survive a future DNS change.

That distinction matters when a site supports enquiries, payments, customer accounts, or an agency handover. The objective is not merely to “turn on SSL.” It is to leave behind a setup whose certificate choice, redirects, renewal process, and failure modes are understood.

Make the certificate decision first

For a production VPS you control, Full (strict) should normally be the target Cloudflare encryption mode. It encrypts the connection to the origin and verifies that the origin certificate is unexpired, covers the requested hostname, and was issued by a publicly trusted authority or Cloudflare Origin CA.

Flexible leaves the Cloudflare-to-origin leg on HTTP. It can be useful during a constrained migration, but it is a poor final design for a VPS you manage and is a common ingredient in redirect loops.

Operating requirement Certificate at the VPS Important consequence
All public traffic remains proxied through Cloudflare Cloudflare Origin CA Simple and long-lived, but normal browsers will not trust it when connecting directly.
Monitoring or vendors connect directly to the hostname Publicly trusted certificate Direct HTTPS works, provided DNS, routing, and hostname validation are correct.
The Cloudflare proxy may be paused during an incident Publicly trusted certificate Avoids certificate warnings during a planned “DNS only” fallback.
The origin must reject traffic that bypasses Cloudflare Either certificate, plus origin access controls TLS validation alone does not restrict who can reach the VPS.
A certificate decision matrix based on how the site must operate, not simply which option is easiest to install.

A dependable Nginx setup

For a conventional site that should always run behind Cloudflare, the implementation sequence is straightforward:

  1. Confirm every required hostname, including the apex and www, is present in Cloudflare DNS and proxied.
  2. Create an Origin CA certificate covering those exact hostnames, or obtain a publicly trusted certificate.
  3. Store the private key with restricted permissions. Do not place it in a repository, ticket, or general client handover document.
  4. Configure Nginx to listen on port 443 and use the matching certificate and key.
  5. Validate Nginx before reloading it.
  6. Switch Cloudflare to Full (strict) only after the origin is ready; otherwise visitors can receive a 526 error.
  7. Test the live application, not just its homepage.

A minimal server block looks like this:

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;

    root /var/www/example/public;
    index index.html index.php;
}

Then test and reload:

sudo nginx -t
sudo systemctl reload nginx

Paths and application directives will vary, but those two commands belong in the operating procedure. A failed configuration test should stop the deployment before it becomes an outage.

When a public certificate is the better operational choice

An Origin CA certificate is intended for connections from Cloudflare to the VPS. If the proxy is disabled, a visitor connecting directly can see an untrusted-certificate warning. Cloudflare also does not currently send expiry notifications for Origin CA certificates, so record the expiry in your own inventory or monitoring system.

If direct access is part of the operating model, use a publicly trusted certificate and test its automated renewal. With Certbot, the familiar commands remain useful:

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

Do not copy an old Certbot installation command without checking the instructions for the VPS operating system. For validation, the ACME HTTP-01 challenge uses port 80. DNS-01 is the practical alternative when that route is unavailable and is required for wildcard certificates. DNS credentials used for automation should be narrowly scoped and protected like any other production secret.

Give redirects one clear owner

Cloudflare, Nginx, and the application may each be capable of enforcing HTTPS or the preferred hostname. That does not mean all three should do it. Assign one layer as the redirect owner and document the decision.

For many business sites, Cloudflare’s Always Use HTTPS is the simplest choice because HTTP requests are redirected at the edge. Cloudflare advises against duplicating this redirect at the origin because conflicting rules can create loops. If Nginx or the application must own redirects instead, disable the overlapping Cloudflare rule and test every hostname.

HTTPS redirection does not repair mixed content. Old http:// image URLs, scripts, fonts, CSS references, and embeds still need investigation. Test forms, login, checkout, admin pages, APIs, webhooks, and OAuth callbacks after changing the scheme or canonical hostname.

Protect the origin separately

Full (strict) authenticates the certificate presented by the VPS; it does not automatically stop direct requests to the server’s IP address. If bypassing Cloudflare would expose an application or avoid its security rules, treat origin restriction as a separate workstream.

Options include allowing only Cloudflare’s current IP ranges at the firewall, using Authenticated Origin Pulls, or adopting a tunnel-based design. Allow for monitoring systems, deployment services, and other legitimate connections before enforcing a block. Roll out the restriction in stages and keep a tested recovery path so a firewall mistake does not lock out the team.

Test the service and leave a usable handover

Before calling the work complete, verify HTTP-to-HTTPS behavior, both canonical hostnames, certificate coverage, forms, authentication, scheduled jobs, callbacks, and monitoring. Review Nginx and application logs for errors that a visual homepage check would miss.

The handover should record the Cloudflare encryption mode, certificate type and expiry, covered hostnames, renewal owner, redirect owner, DNS proxy status, relevant firewall controls, and rollback steps. This is the difference between a configuration that works today and one another operator can safely maintain.

If your Cloudflare and VPS setup has accumulated certificates and redirect rules through trial and error, Greg can review the full path, remove conflicting assumptions, and leave your team with a clearer operating model.

Related on GrN.dk

  • Shorter TLS Certificates Make Renewal Monitoring a Server Job
  • A stray Set-Cookie can waste your CDN: audit the cache at the edge
  • How to Bulk Delete Cloudflare DNS Records Without Browser Console JavaScript

Need help with this kind of work?

Ask Greg to review your Cloudflare SSL setup Get in touch with Greg.

Sources

  • Cloudflare Docs: Full (strict) SSL/TLS Encryption Mode
  • Cloudflare Docs: Origin CA Certificates
  • Cloudflare Docs: Always Use HTTPS
  • NGINX Docs: Configuring HTTPS Servers
  • Let’s Encrypt Docs: Challenge Types
Last modified
2026-08-01

Tags

  • Cloudflare
  • SSL
  • VPS
  • Nginx
  • TLS
  • Log in to post comments

Review Greg on Google

Greg Nowak Google Reviews

 

Illustrated infographic summarizing: Prompt Caches Have Write Costs Now—Audit What Your Workflow Reuses
Prompt Caches Have Write Costs Now—Audit What Your Workflow Reuses
2026-08-10

GPT-5.6 makes cache writes billable. See how to spot wasted writes, stabilise prompt prefixes, place breakpoints and measure whether caching pays.

Illustrated infographic summarizing: The AI Crawler in Your Logs May Be Wearing a Borrowed Name
The AI Crawler in Your Logs May Be Wearing a Borrowed Name
2026-08-09

A User-Agent is a claim, not proof. See how to verify AI crawler traffic before it shapes reporting, robots.txt decisions, or WAF exceptions.

Illustrated infographic summarizing: AI Agents Need a Spending Brake, Not Just a Billing Dashboard
AI Agents Need a Spending Brake, Not Just a Billing Dashboard
2026-08-08

AI agent costs can climb inside a single workflow. Runtime budgets, loop detection, outcome metrics, and safe handoffs keep that spending under control.

Illustrated infographic summarizing: Drupal 12 Slipped to December. Drupal 10 Still Runs Out of Road
Drupal 12 Slipped to December. Drupal 10 Still Runs Out of Road
2026-08-07

Drupal 12 arrives as Drupal 10 support ends in December 2026. Moving to Drupal 11.3+ first keeps two mandatory upgrades manageable.

Illustrated infographic summarizing: EU OpenAI Residency Is a Migration Project, Not a Dashboard Toggle
EU OpenAI Residency Is a Migration Project, Not a Dashboard Toggle
2026-08-05

An EU-resident OpenAI API setup needs a new project, regional routing, dependency and state migration, compatibility testing, and clear governance evidence.

Illustrated infographic summarizing: AI Images Need a Chain of Custody, Not Just a Disclosure Label
AI Images Need a Chain of Custody, Not Just a Disclosure Label
2026-08-04

AI image labels are only the endpoint. Learn how to test C2PA credentials through editing, CMS, CDN and agency handoffs while preserving evidence.

Illustrated infographic summarizing: MCP Just Went Stateless: Audit the Integrations Behind Your AI Tools
MCP Just Went Stateless: Audit the Integrations Behind Your AI Tools
2026-08-03

The 28 July 2026 MCP release removes protocol sessions and changes discovery, tasks, caching, OAuth and tracing. A practical guide to auditing the move.

Illustrated infographic summarizing: SEO Trends for 2026: What Actually Changed Since 2024
SEO Trends for 2026: What Actually Changed Since 2024
2026-08-03

A practical guide to what changed in SEO between 2024 and 2026, from AI and multimodal search to Core Web Vitals, privacy and local visibility.

Illustrated infographic summarizing: INP and Green SEO Share a Backlog: Cut the Work Every Visit Repeats
INP and Green SEO Share a Backlog: Cut the Work Every Visit Repeats
2026-08-03

INP and sustainable web work often expose the same waste. Use field data, profiling, caching and performance budgets to build one practical backlog.

Illustrated infographic summarizing: AI crawler policy now has verbs: separate search, RAG, and training
AI crawler policy now has verbs: separate search, RAG, and training
2026-08-02

AI crawler rules now need separate decisions for search, RAG, and training, backed by practical testing across robots.txt, CDNs, WAFs, and CMS controls.

More articles
RSS feed

Footer

  • All articles
  • Contact

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.