Can Ghost CMS issue a Let's Encrypt certificate for a custom domain when DNS A records resolve to the server but the public URL is set to a different hostname?
0 reputation · 23 Apr 2021, 03:04 UTC
0 reputation · 23 Apr 2021, 03:04 UTC
Ghost CMS’s `ghost setup ssl` command provisions Let’s Encrypt certificates only after the domain’s DNS A or CNAME record resolves to the Ghost instance; if the public `url` stored in config.production.json points to a different hostname, the certificate’s subject name will not match incoming requests.
When a reverse proxy terminates TLS, Ghost typically runs over HTTP and relies on forwarded headers, which can cause asset URLs and redirects to reference the wrong hostname, further complicating certificate validation.
Can Ghost issue a Let’s Encrypt certificate for a custom domain when DNS resolves to the server but the `url` config points elsewhere? Does the built‑in ACME HTTP‑01 challenge require the domain to resolve to the server, or can DNS‑01 be used instead? If the `url` value differs from the certificate’s CN, must `ghost setup ssl` be re‑executed to align them?
35775 reputation · 23 Apr 2021, 14:27 UTC
Ghost cannot issue a Let's Encrypt certificate when the public URL in config.production.json differs from the domain whose DNS A record points to the server. The built-in ghost setup ssl command uses HTTP-01 validation exclusively and requires the domain in the url config to resolve to the same Ghost instance.
When you run ghost setup ssl, Ghost:
url from config.production.json
/var/www/ghost/content/.well-known/acme-challenge/
http://<url>/.well-known/acme-challenge/<token>
If DNS for that url does not resolve to your Ghost server, Let's Encrypt receives a connection error or a different response, and validation fails.
Ghost's ghost setup ssl does not support DNS-01 validation. The command is hardcoded to use the HTTP-01 flow through the ACME proxy. You would need to manually obtain a certificate using tools like certbot with DNS-01, then configure Ghost to use it—but this bypasses Ghost's automated renewal mechanism.
Align the url config with your custom domain before running SSL setup:
ghost config url https://your-custom-domain.comghost setup sslIf using a reverse proxy, ensure X-Forwarded-Proto and X-Forwarded-Host headers are set so Ghost generates correct redirect URLs after TLS termination.
ghost config — check current url valuedig your-domain.com +short — confirm IP matches Ghost servercurl -I http://your-domain.com/.well-known/acme-challenge/ from outside the server — should return 404 (expected before SSL setup)Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.