Subdomains on custom domain

Hi! I wanted to know if it was possible with Fastly to add subdomains to a custom domain pointing to a glitch website. How would the file tree look? Is this possible?

Hi @MilesWK!

I haven’t tried this so there may be a simpler way but here you go anyway…

You can’t make subdomains on your glitch.me site, so at that end you could either use separate Glitch projects, or paths (folders) in a single Glitch project – your Fastly service would have the glitch.me domain as host.

You’d need to add the subdomain in your DNS settings and point it at Fastly using the same technique as for the domain in general (in the Fastly service and TLS certificate – unless you use domain wildcards).

To point a Fastly request at a path in your Glitch project I believe you’d need to use custom code in VCL or Compute (in that case you’d need a Compute service instead of a CDN one), like this: Rewrite url based on the subdomain | Fastly Documentation

It would be a little messy to set up but with some custom config in your Fastly service it should be possible.

1 Like

wouldn’t that allow anyone (not only the domain owner) to make xxxxx.mydomain.com show the contents of xxxxx.glitch.me, making it a pretty big security risk?

Only the owner of a domain can point it anywhere (at a Glitch site or otherwise) as you need to do that in your DNS settings wherever your domain is registered. To do this through Fastly involves updating your DNS to point at Fastly’s servers. Does that answer the question?

1 Like

Yeah but I was talking about if if you set glitch.me as a host

You can point a domain more or less wherever you like, there are workarounds to try to stop people pointing at your content but they are pretty rarely used in my experience, it’s just how the web works!

1 Like

I was referencing if the reverse would be possible, e.g. if you set glitch.me as the host (not myproject.glitch.me), could you access evilproject.glitch.me by visiting evilproject.mydomain.com?

The only way for evilproject.mydomain.com to point at the content at evilproject.glitch.me is for evilproject.glitch.me to be included as the host (not glitch.me on its own).

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.