Fix cloudflare error 526
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:
- two containers: one for root, another for api
- two SSL cert for two domain: one is root, another is api.root
Extra Knowledge:
- SAN(Subject Alternate Name) cert is a cert supporting multiple domains. You can create one with root and api.root domain.
- 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.