Skip to navigation
Use Cloudflare ssl and proxy DNS example
13.11.26
# couchdb.tibellus.com — Cloudflare proxy + Froxlor + Origin CA certificate ## Situation - CouchDB runs on a server at `127.0.0.1:5984`, fronted by nginx (inside Froxlor) under the vHost `couchdb.tibellus.com`. - DNS for `tibellus.com` lives at **Cloudflare**. The `couchdb.tibellus.com` record can be proxied (orange cloud) or DNS-only (grey cloud). - Froxlor manages TLS certificates for the domain and normally renews **Let's Encrypt** certificates automatically. ## Why Let's Encrypt breaks behind the orange cloud Froxlor's Let's Encrypt integration (since v2, ACM E) uses **HTTP-01 validation** via acme.sh with a fixed webroot. Before issuing, Froxlor checks that the domain's A/AAAA records resolve to *this server's* IPs. With the orange cloud on, the record resolves to Cloudflare's edge IPs (`104.x` / `172.x`), so Froxlor refuses: The domains DNS does not include any of the chosen IP addresses. Let's Encrypt certificate generation not possible. There is **no DNS-01 option** in Froxlor 2.3.17 (only http-validation; wildcard certs are not supported for the same reason). Workarounds otherwise: grey the record temporarily for every issuance/renewal, or use a certificate that does not involve Let's Encrypt. The Let's Encrypt path through orange cloud is not a reliable, documented option. ## Decision: Cloudflare Origin CA (chosen, works) Visitors see Cloudflare's Universal SSL at the edge; the origin serves a Cloudflare **Origin CA** certificate trusted only between Cloudflare's edge and this server. Validity: **up to 15 years** — no renewals. ### 1. Create the Origin CA certificate (Cloudflare dashboard) 1. Cloudflare → `tibellus.com` → **SSL/TLS → Origin Server → Create Certificate**. 2. Choose: - *Generate private key and CSR with Cloudflare* (simplest), - Hostnames: `*.tibellus.com, tibellus.com`, - Validity: **15 years**. 3. Copy the **Origin Certificate** (PEM) and **private key** — the key is shown only once. Store both; example location on the server: `/root/tibellus-origin.crt` / `/root/tibellus-origin.key` (`chmod 600` the key). ### 2. Install it in Froxlor 1. Froxlor → **Resources → Domains** → edit **couchdb.tibellus.com**. 2. **Untick `Use Let's Encrypt`** (the domain no longer uses ACME). 3. Keep **Enable usage of SSL** (and *SSL redirect* if desired). 4. The SSL editor appears in the domain editor. Paste: - Origin Certificate PEM → certificate field, - Private key PEM → private key field. - *Chain/intermediate:* leave empty — Cloudflare's edge trusts its own Origin CA; no chain is needed at the origin. 5. Save, let Froxlor regenerate/reload (`bin/froxlor-cli froxlor:cron` forces a config refresh if needed), nginx reloads. ### 3. Set Cloudflare SSL mode - **SSL/TLS → Overview → Full (strict)**. Never use *Flexible* (plain HTTP to the origin). *Full (strict)* is satisfied by the Origin CA certificate. ### 4. Verify - Outside: `curl -I https://couchdb.tibellus.com/` → CouchDB response, no certificate error. - On the server: `openssl s_client -connect 127.0.0.1:443 -servername couchdb.tibellus.com` → handshake shows the Origin CA certificate. - Browser shows the **Cloudflare Universal SSL** cert — correct; the origin certificate never reaches visitors. ## The nginx block (Own SSL vHost-settings) Unchanged by any of the above — cert choice is independent of the proxy config: ```nginx location / { proxy_pass http://127.0.0.1:5984/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; add_header Access-Control-Allow-Origin "https://www.tibellus.com" always; add_header Access-Control-Allow-Methods "GET, PUT, POST, DELETE, HEAD, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; if ($request_method = OPTIONS) { return 204; } } ``` CORS notes: - `Access-Control-Allow-Origin` must be the origin of the *page making the requests* (e.g. `https://www.tibellus.com`), not the CouchDB host. - If the frontend is same-origin or calls CouchDB server-side, omit CORS entirely. - If the frontend authenticates via CouchDB session cookies from another origin, add `add_header Access-Control-Allow-Credentials "true" always;` (exact origin already set — `*` would never work with credentials). - Method list must cover sync writes (`PUT`, `DELETE`, `HEAD`). - Non-SSL vHost-settings can also be included in the SSL vHost (domain editor: *Include non-SSL vHost-settings in SSL-vHost*) if you prefer to maintain one block. ## Gotchas - The Origin CA certificate is trusted **only** Cloudflare ↔ origin. If the record ever goes back to grey cloud (DNS only), browsers will see it as an untrusted certificate — keep it orange, or switch back to Let's Encrypt (grey) / DNS-only certs in that case. - Origin CA certs can't be used for anything directly served on the public internet. - Froxlor's docs: Let's Encrypt = http-validation only; wildcard not supported. Any "DNS-01" for Froxlor's built-in renewal does not exist in 2.3.17 — check docs.froxlor.org before upgrading expectations. - Froxlor cron drives renewals: `bin/froxlor-cli froxlor:cron` (`--debug` for output, `-N` no-fork for the traffic job). - Froxlor never accepts challenge configs for wildcard certs via its own ACME — keep a wildcard need on the Origin CA side (allowed, it covers `*.tibellus.com`). - `Own (SSL) vHost-settings` contents are dropped into the vHost as-is; a syntax error prevents nginx from starting — review the generated vHost after each save. - If the Origin CA private key is lost, simply create a new certificate — no ACME limits apply.
Reply
Anonymous
Information Epoch 1795523555
Make every program a filter.
Home
Notebook
Contact us