Fix cloudflare error 526

frontend

Error 526: Invalid SSL certificate

This error indicates that a service doesn’t use a valid SSL certificate. It’s the follow-up of error 1003.

My api deployed to a subdomain in Nginx, but the subdomain cannot use the same SSL cert with the root domain, unless a SAN cert supporting multiple domains is used. But my root domain uses the cert generated by let’s encrypt with VIRUTL_HOST setup. It only supports one cert.

So the solution is straight forward, just add a new cert for my api container for subdomain. Now the docker compose structure is like this:

  1. two containers: one for root, another for api
  2. two SSL cert for two domain: one is root, another is api.root

Extra Knowledge:

  1. SAN(Subject Alternate Name) cert is a cert supporting multiple domains. You can create one with root and api.root domain.
  2. Wildcard cert is a cert like *.example.com it supports all domains like api.example.com, www.example.com but doesn’t support root domain example.com.