The issue is probably happening because of cloudflare proxy. You’ll have to disable cloudflare optimization by clicking orange cloud and making it grey on the DNS page in cloudflare for the given (sub)domain. If you’d rather have cloudflare, You’ll need to edit the configuration file manually to disable the discourse built in ssl.