2
11 Comments

How can a user point his site to my SaaS website?

I am making a SaaS app where users can create websites

Now when a user (say John) creates a website, they will get a preview url where they can preview their websites, john.saasapp.com

Now John decides to buy his own URL called john.com

What should John do to point john.com to john.saasapp.com ?

My Guess For hosting

  1. What I'm thinking is for Hosting my SaaS App *.saasapp.com, I found Vercel which has the ability to host wildcard domains, so now *.saasapp.com would point to saasapp.com(and then I would do window.location.href and grab the subdomain value and then query it with DB to display his site) --- is there any better way to do this?

  2. What about users pointing their own john.com custom domains to this? I do not know how that would work. If John makes an ALIAS record in his DNS Manager which points to john.saasapp.com would it resolve correctly? (I would later grab john's values byjohn.com against my database)

What do you think?

on June 4, 2020
  1. 1

    You can set-up a wildcard DNS record for your own domain (ie. *.saasapp.com), you shouldn't need any special service to do this. You can then get your client to point their apex domain at your server IP.
    You may also want to consider adding a reverse proxy into the mix, I've been using https://caddyserver.com/ to provide automatic https, and it also has an admin API which you could make use of to automate the whole ordeal.

    1. 1

      Please can you help with your setup on this?
      Or any tip using caddy 2.

      1. 1

        You can check out their documentation:
        https://caddyserver.com/docs/caddyfile

        For my own set-up, I have an EC2 instance with caddy running as a service (https://caddyserver.com/docs/install#linux-service), then I have a CaddyFile which looks a little something like this - where fizz.com and buzz.com are client domains, and my_origin_server.com is my app server. I then have tls on _demand, which means that a lets encrypt cert is requested the first time a request comes in from one of these domains. The benefit of doing it on demand means we can have this all set-up in advance before the client has updated their DNS records.

        fizz.com, www.fizz.com,
        buzz.com, www.buzz.com
        {
        reverse_proxy my_origin_server.com:1234
        tls {
        on_demand
        }
        }

    2. 1

      Hey Chris! Thanks for replying

      But a few things here that I forgot to mention,

      I'd want them to point their custom domain as a CNAME record to myappdns.com and this would be pointed to the IP Address of my server

      Also, if I provision my own http server, I should be doing tons of maintenance and devops for it. (uptime, crash, etc)

      All my app is, is a simple static build that needs to served & a simple REST API server for lookup queries.

      I would also have to account for user traffic along with the user's website's traffic.

      So I was wondering if there a is a backend platform which can take care of all this in a scalable way?

      1. 1

        I'd want them to point their custom domain as a CNAME record to myappdns.com and this would be pointed to the IP Address of my server

        CName will work fine for subdomains (ie. foo.clientsite.com -> myappdns.com), however apex/naked domains will have to point at the IP via an A record, or you can use a new fangled AName record which isn't massively support by DNS providers. (ie. clientsite.com -> 23.23.23.23)

        Another thing to think about is setting up SSL for your clients (which is why I mentioned the reverse proxy).

        Also, if I provision my own http server, I should be doing tons of maintenance and devops for it. (uptime, crash, etc)

        If you're referring to the reverse proxy, I believe there is a maintained docker image available for caddy.

        I'm afraid that I'm not aware of any backend platform that takes care of all of this for you.

  2. 1

    Okay, I'm settling using Digitalocean Droplet with Nginx

    Apparently, I need to configure Nginx to "accept" any domain (like john.com)

    And then when someone visits john.com it resolves to the Digitalocean drop automatically.

    I'm still testing it, so let's see how it goes! 🤞

    1. 1

      Hi

      Did you figure this out? I'm struggling to know the right keyword to Google for this.

      Thanks
      ZubairLK

      1. 1

        Hey, you need to setup NGINX on Digitalocean and make it accept requests from yourdomain.com via the server_name setting. You can set a wildcard for server_name so that it will accept any domain

        1. 1

          Hey, did you find any good guides or could provide any advice on this? I'm in the exact same boat as you (tried using Vercel, realized it wont work, moved to DO), but I'm terrible with NGINX.

          1. 1

            I did it myself. You can do it with NGINX or Caddy too maybe

        2. 1

          Thanks!

          I'm wondering if I can do this with a bubble.io app :)