User custom domain on app subdomain and SSL

Hello,

I’m building an app where user can host their dashboard pages on app subdomain - username.myapp.com. App is hosted on Fly.io, I’ve set everything up and subdomains work just fine. The problem is when users want to connect their custom domain to point to their subdomain. I use cloudflare in front and users are getting Cloudflare Error 525 - SSL Handshake Failed.

The thing is, I’ve never built something like this and I don’t really understand how to setup SSL properly. I know I could create certificates on Fly for each user custom domain but is there a better way?

As I said, I don’t have experience with this so I would really appreciate some overview and pointers how something like this should be done.

Thanks

From your post, it’s really hard to understand what is your deploy topology, are you using cloudflare tunneling or managing your dns records? Also, from where you are serving your https certificates and do you use separate certificates for each subdomain or a wildcard certificate?

I use wildcard certificate for all subdomains, *.myapp.com. Currently I have two of them on Fly, *.myapp.com and myapp.com. I use Cloudflare for dns records and have SSL protection set to full. I don’t know if this is the best way but this is what I have so far.

What for? If you are using fly to terminate ssl, then cloudflare should have only the A record set to point to your server IP, nothing more as it cannot decrypt the traffic. If you are using something like captcha provided by cloudflare, then you most probably need to terminate ssl at cloudflare level.

As I said, I don’t have experience with this so I’m probably doing things wrong, that’s why I’m asking here.

So, my DNS settings are:
CNAME www my.app.com
CNAME * my.app.com
CNAME @ my.app.com

I don’t use captca, I just use Cloudflare for DNS.

All I want to build really is the ability for users to connect their custom domains to their subdomains on my app. And to be honest, I have no clue how to set it up correctly.

This is just a test app so no real users here so I can change everything, and I just want to learn this thing and I’m completely lost.

1 Like

From a cursory search it sounds like Cloudflare returns error 525 if there are SSL issues between the Cloudflare proxy and your server.

If you are only using Cloudflare for DNS, why is it connecting to your server? Where are you seeing this error?

Cloudflare has a tunnel checkbox enabled by default when creating new records, make sure that it’s disabled for all the records.

3 Likes

Ooook… this “magically” fixed the problem… :grinning: this is why AI won’t replace developers so soon… thanks a lot!

1 Like