Skip to main content
Home
GrN.dk

Main navigation

  • Articles
  • Cases
  • Services
  • Your Digital Project Manager
  • About Greg Nowak
  • Image Gallery
  • Contact
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

Illustrated infographic summarizing: 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-12

Tags

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

Review Greg on Google

Greg Nowak Google Reviews

 

Written recommendations from Trafik og Veje, Aarhus Municipality (2011) and AgroTech (2010) — read them on LinkedIn.

Illustrated infographic summarizing: Zero Data Retention Is a Workflow Audit, Not a Checkbox
Zero Data Retention Is a Workflow Audit, Not a Checkbox
2026-08-30

Zero Data Retention covers the provider, not every copy in your stack. See how to audit endpoints, logs, storage, deletion and project-level controls.

Illustrated infographic summarizing: MCP 2026-07-28 Is an Auth Migration, Not a Version Bump
MCP 2026-07-28 Is an Auth Migration, Not a Version Bump
2026-08-29

MCP’s July 2026 release removes protocol sessions and tightens OAuth. Here’s a practical plan for migrating clients, servers and enterprise access safely.

Illustrated infographic summarizing: Turn a Technician’s Voice Note into a Work Order—Not Raw Audio
Turn a Technician’s Voice Note into a Work Order—Not Raw Audio
2026-08-28

Voice input can reduce the technician’s documentation burden when hours, materials and status are validated before the information is saved in the work order system.

Illustrated infographic summarizing: ChatGPT Disabled Personal Knowledge Sync. What Broke on Your Team?
ChatGPT Disabled Personal Knowledge Sync. What Broke on Your Team?
2026-08-27

ChatGPT retired personal sync connections for Enterprise and Edu. Here is how to find affected workflows, migrate access, and test permissions.

Illustrated infographic summarizing: Cloudflare’s September Bot Defaults Could Quietly Cut AI Visibility
Cloudflare’s September Bot Defaults Could Quietly Cut AI Visibility
2026-08-26

Cloudflare’s September bot defaults give publishers more control, but one training block could also cut search crawling and AI-driven discovery.

Illustrated infographic summarizing: Does Your AI Chatbot Clearly Identify Itself?
Does Your AI Chatbot Clearly Identify Itself?
2026-08-25

The EU’s transparency requirements for AI chatbots now apply. Here is how to make your bot’s identity clear, limit its system access and provide a genuine route to a member of staff.

Illustrated infographic summarizing: Should publishers add Google’s new Preferred Sources button?
Should publishers add Google’s new Preferred Sources button?
2026-08-24

Google’s Preferred Sources button is worth a controlled test for eligible publishers, with careful choices around placement, performance and measurement.

Illustrated infographic summarizing: Search Console Can See TikTok Now. Your Reporting Has to Catch Up
Search Console Can See TikTok Now. Your Reporting Has to Catch Up
2026-08-23

Google can now report how social profiles appear in Search. Here is how to measure cross-channel discovery without mistaking visibility for business results.

Illustrated infographic summarizing: Your AI workflow has logs. Can they explain one bad decision?
Your AI workflow has logs. Can they explain one bad decision?
2026-08-22

Logs can show that every service worked while leaving a bad AI decision unexplained. See how connected traces and careful redaction close the gap.

Illustrated infographic summarizing: Security Questionnaires Eat Into Selling Time—Let AI Find the Evidence
Security Questionnaires Eat Into Selling Time—Let AI Find the Evidence
2026-08-21

NIS 2 is generating more supplier questionnaires. A controlled AI assistant can find approved answers and sources—and route uncertain cases for review.

More articles

Built by AI — available for your business. The daily articles on this site are researched, written and illustrated by an autonomous AI pipeline. At nowa.dk I install the same kind of AI automation in businesses at fixed prices — site in Danish, English version here, and web/marketing agencies have a dedicated page.

RSS feed

Footer

  • All articles
  • Contact

GrN.dk — AI automation, web platforms, web optimization, data handling and logistics.

© 2026 GrN.dk · LinkedIn · Contact · AI automation in Danish: nowa.dk

Behind GrN.dk: Individual Entrepreneur Codecrafter · Tax ID 305669096 · Bakhtrioni St. 22, 0194 Tbilisi, Georgia · official business register