[Tutorial] Get your Glitch project on a domain!

Hey there! Many Glitch users probably wan’t their Glitch project on a custom domain. That’s why I’ve made this tutorial for you to use!

Note: this tutorial is long, but it does have pictures! :smiley:

Step 1: Setup your glitch project

You obviously need a Glitch project to work with, so first go ahead and create one.

But wait… You aren’t going to get away with just making an sort of Glitch project.

You need to make a Hello Express project.

We’re nearly done with step 1 but next is security.

Now we have our express server running, we should force HTTPs.

To do so place the following code in your express server’s code:

function checkHttps(req, res, next){
  // protocol check, if http, redirect to https
  
  if(req.get('X-Forwarded-Proto').indexOf("https")!=-1){
    return next()
  } else {
    res.redirect('https://' + req.hostname + req.url);
  }
}

app.all('*', checkHttps);

But, it must go first. Put it after var app = express(); Thus, making sure it is the first thing checked.

Step 2: Get your Glitch app flying

Ahh, here we finally are: step 2.

First, create an account at fly.io. It should be dead simple.

Now, log into your account if you haven’t already.

Navigate to the button where it says Sites and click it. If the button isn’t there go to https://fly.io/sites

It will redirect you to a page like this:

Now you can click the big button that says Add new site!

Then you will reach this page:

Select the Hosting Service radio button then click the button beneath that says Glitch

An extra little box will appear bellow:

In it type your Glitch project domain. Be careful!

Instead of https://myproject.glitch.me or http://myproject.glitch.me put myproject.glitch.me. Since fly doesn’t accept the http or https part.

Now you can click Preview your site.

Then you can click Set your hostname!
You will be greeted with another prompt.

Now type in the hostname your going to use. For example I’d put in mywebsite.tk

Now click Next, configure DNS.

It will bring you to a different screen.

Ignore what it says and just click the button that says Got it!

You will then be welcomed to a magical dashboard that looks like this:

That’s the end of step 2!

Step 3: Get your app on your domain!

Now it’s time to get out some wizardry magic.

POOF.

Ok, so open up a terminal (Linux & MacOS) or Command Prompt (Windows).

Then on your magical dashboard open the preview link. (Preferably in a new tab).

If it says something like Not Found then you’ll just need to wait. But you can still carry on this guide.

Now in your terminal type the following:

Note: Remove the https / http from the URL before pasting it bellow.

  • Windows users:
ping PUTYOURURLHERE
  • Linux/MacOS users:
dig PUTYOURURLHERE

Now you will notice an IP will display on the screen.

Example (Command Prompt):

Example (Terminal):

Now write down the IP on a piece of paper or just type it out into Notepad or something. You’ll need your IP later.

  • Now go to your DNS provider’s DNS managment area -

Now, this is where the IP comes in usefull.

You’ll get a box similar to this:

Now, leave the Name part alone.

Now set the TTL part to 14440.

In the Target box enter the IP address you wrote down.

Now save that then your nearly done.

Now, go back to your magic control panel. Then click Middleware

image

You will then be taken to a page that will look like this:

You can enable whatever you want but you must click the Add button for HTTPS Upgrader.

That’s it! You should be set to go!

Note: It can take while for your DNS provider’s name servers to update!

Thanks for reading!

Have a nice day!

This took me quite a while to produce, so I’d love your feedback!

Note: Thank you for all the :heart:!

45 Likes

I don’t understand step 1 how do I make a project “Hello Express”? I followed all other steps but idk what to do now

1 Like

it’s no longer required, custom domains have now be included in glitch

5 Likes

Ohhhh How do I do that exactly/

1 Like

Hello @smorezsun, before you can use the built-in Glitch custom domains first you need to help a couple of folks out in the the glitch.com help area

image

Built-in custom domains are a feature that’s turned on for people who are helping out others in the community.

Until you’ve racked up a couple of “Thanks!” notes you can still use this Tutorial to set up a custom domain using fly.io. To answer your question,. the “Hello Express” app mentioned here is just an example - you can use any Glitch project for the subsequent steps.

3 Likes

oh ok. I help people on threads? How many do I have to help

1 Like

The custom domains are a recognition for being thanked for your help anywhere in the Glitch community; you can read a little more about the feature at https://glitch.com/help/how-can-i-get-help-with-code-in-my-project/.

One common way to help people and be thanked is to see someone asking for help on the glitch.com homepage (that’s where the picture I included is from) but people can thank you for anything, including helpful comments in the forum. You’ll have to be thanked twice for the custom domains feature to become available. Once active on your profile you’ll see it under each project’s Advanced Options menu:

image

image

4 Likes
`    I am having a pro. blem
    I did everything as was said.
    But it throws ERR_NAME_NOT_RESOLVED
     Please help
    Images

    If anyone is wondering
    I am using freenom
    As same as the tut.~~

ignore what I said above.

1 Like

It takes a while for domain names to process through. They’re usually ready in 48 hours or less.

2 Likes

I just don’t think they’re ready yet…
I keep having problems like invisible assigned domains (x is used by another project already etc.).
This apparently also is a common problem in the support forum here…
I’n now using my own method (see my glitch project znw-router) and propagations and changes now reflect in seconds.
So, if you want a proper solution until glitch fixes it for everybody, you can use my method(proxying the full request/response) (requires a dedicated glitch project / node instance for the routing).

2 Likes

I’ll agree that there’s still a fair amount of work to be done on Custom Domains; we wanted to get it out to you folks as soon as we could and released a small MVP (minimum viable product) of the feature so people could start using it. We’re also aware of a new bug meaning that new custom domains don’t display the necessary shw.io domain when you add one. Support is happy to assist with either of these issues whenever they arise, and we’re sorry for the inconvenience.

That said there are over 500 custom domains associated with Glitch projects so far, so it’s clearly going well for some folks at least, and often without any direct support from us.

All of that said, however, the Custom Domain solution we’re still working on isn’t going to work for everyone in every case, and we’re always happy to see community members come up with and share the solutions that work for them, So thanks for posting this!

Lastly, @blubbll I’m happy to continue working directly with you to get your custom domains working in Glitch if you’d like. That goes for anyone else who’s having problems with the Custom Domains feature (which isn’t simple in the best of times because nothing related to DNS ever is as simple as we’d hope it would be) as well!

1 Like

Can you multiple ports when you have a custom domain?

1 Like

Hi @MKDev, no, the port routing is unrelated to domains. Right now we don’t have any plans to change the port scheme, even in some of the paid tiers that we are considering - changing how we handle ports would take pretty substantial work across our entire infrastructure.

2 Likes

i cant see the sites tab ): please help

1 Like

You shouldn’t have to use that method any more - you can add a custom doamin from within Glitch directly from the Tools menu in the bottom left of the editor. More detail here: https://glitch.com/help/custom-domain/

1 Like

I cant get anybody to help

1 Like

How far in the outlined process above did you get before getting stuck? If you let me know the specific issue you’re having then I can help. Unfortunately, we can’t set it up for you.

1 Like

There is no “Sites” tab anywhere

This does not exist

1 Like

1 Like

Sure, but as I mentioned above, you don’t need to use that method to add a custom domain any more - you can add a custom doamin from within Glitch directly from the Tools menu in the bottom left of the editor. More detail here: https://glitch.com/help/custom-domain/

1 Like

Again: I cannot get thanks. I cant find ppl who want help…

This never shows up with somebody.

1 Like

Ah, I understand now. I have more thanks on the site than anyone else, but I haven’t helped the most people - the majority of the thanks came from creating useful resources that other people valued. I suggest you try doing the same.

Meanwhile, does going to https://fly.io/sites directly work?

4 Likes

YESS THAT IS WHAT I WANTED!!!:exploding_head::triumph::triumph::joy::smiley:

2 Likes

Glad you got what you needed! :slight_smile:

  • Now go to your DNS provider’s DNS managment area -.

    How can i get there?
1 Like

Hey @LeeeRoux, welcome to the Glitch forum!

This depends on who your DNS provider is. You can see a couple of examples at https://glitch.com/help/custom-domain/, but if you let us know who you use for your DNS someone might be able to provide specific guidance.

2 Likes

Hey @cori , Thanks for helping.

I got it already, Sorry i didn’t think about it before asking :sweat_smile:

1 Like

this comment should be pinned or something

1 Like

Hey, @lucasverra! Welcome to the Glitch Forums!

For some people Glitch’s built in custom domains may not be an option because you require 2 thanks in Glitch.

Also, while your using Glitch’s custom domains you miss out on lots of extra custom features.

Personally, I do it the manual way as I have more control over my domain and it’s easier to troubleshoot (sometimes).

I believe the built in domains for Glitch are good for people that just want to get their project on a domain without any extra customisation. However, for the more experienced users the manual way maybe a better option.

Happy glitching!

7 Likes

thanks for the insight, make sens.

1 Like

To clarify confusion, here’s a quick note:
fly.io/sites is getting deperecated so it does not show on the main topbar.
if you are not logged in to fly.io it will say “four-oh-four, maybe lost”
logging in to fly the percedding to fly.io/sites will give you the fly.io sites interface
Update: Fly.io has given us the stick and we cannot access fly.io/sites

5 Likes

Thanks for the clarification which should help newer users. Whilst the sites part is getting deprecated, using normal Edge Apps will cost.

How can I configure these DNS?
Help me please!!! :’(

  1. screen -> https://paste.pics/85561f9378ae067c04822c51059da086
  2. screen -> https://paste.pics/d493eba880993c33c9dbec99beb4e2f1

Hey @SuperColy,

To configure your DNS,

At freenom.com

  1. Go to My Domains.
  2. Click on Manage Domain
  3. Click on Management Tools
  4. Click on Nameservers
  5. Select Use default nameservers
  6. Press Change Nameservers

Then, you can set up your DNS records, by going to
the Manage Freenom DNS area.

  1. Go to My Domains
  2. Click on Manage Domain
  3. Manage Freenom DNS

Now you can enter a variety of different DNS records,
including A, MX and CNAME records.

But what we need to enter is the CNAME record. You will get a box like this:

  1. Now, leave the Name part alone. Now set the TTL part to 14440 .
  2. In the Target box enter the IP address you wrote down in step 3 of the original post
  3. Now save that then your nearly done.

Then proceed from

2 Likes

Hey am I able to get some help? I did all the instructions but it’s not appeared to have worked.

I think I did something wrong in the last part , I am not sure if I am in the right place on my DNS Provider’s DNS management area because I get the following options instead of the name/type/TTL/target fields from the instructions

i’m using squarespace as my DNS provider btw.

where do I type
"Now set the TTL part to 14440 ."

? I am not allowed to type anything into the HOST or PRIORITY boxes (RECORD is set to A, and in DATA i put my IP address and i tried a few because i got given 3)

also in there, there are about 5 other IP addresses already in the fields (on squarespace that is) so should i delete those or?

also in step one I ignored that part and none of this code is in my site, does it need to be?

function checkHttps(req, res, next){
// protocol check, if http, redirect to https

if(req.get(‘X-Forwarded-Proto’).indexOf(“https”)!=-1){
return next()
} else {
res.redirect(‘https://’ + req.hostname + req.url);
}
}

app.all(’*’, checkHttps);

The TTL part is not required as most providers do it automatically.
———
You don’t need the checkHttps function.

1 Like

Thanks so much. I’ve tried many times to do it and use all the different settings but still no luck.

This is the error I get now "DNS RECORD CONFLICT: There cannot be an apex (@) CNAME record.

However this is what fly.io is telling me to do:
Screenshot 2019-12-22 at 21.19.20

There is also the custom nameservers section on squarespace - should I select “use squarespace nameservers” or “custom nameservers” ? (and what would those be?)

Ah. It seems Squarespace doesn’t support CNAME flattening.

Custom name servers is if you want to use a different DNS provider. I personally use Cloudflare DNS as it supports many many features (including CNAME flattening) + free SSL. I also recommend Cloudflare as it just eliminate most issues.

Thanks I realised that I needed to type my IP address into the DNS records section now though and I had the wrong one …

so now it’s like this … but it still doesn’t work…should those CNAMEs be the ones from cloudflare ??

The name servers should be the ones Cloudflare provides you with.
Then you use Cloudflare’s DNS to add your .shw.io CNAMEs.

Still not working

thanks so much for your patience on this…

so now my name servers are the ones Cloudflare provided me with which are these (does it look correct?)
Screenshot 2019-12-23 at 12.06.40

Then I used cloudflare’s DNS to add my shw.io CNAMES
this is what it looks like on cloudflare (is that first one that just says www correct?)
Screenshot 2019-12-23 at 12.07.41

and then I am still using the shw.io CNAMES on squarespace in the DNS records section??
Screenshot 2019-12-23 at 12.08.59

I think for me i’m just confused about what information is going where … i’ve tried a lot of different combinations to crack it but still broken… :frowning:

ah wait I deleted everything and started the instructions in the first post from scratch… I get this error on fly.io right at the beginning when I add my site… could this be the problem?

Click on the temp link and if your site shows fine just press Continue Anyway (it happens to me a lot).

Thanks, but the method didn’t work so I have deleted my fly.io account and cloudflare account and now i’m trying the standard glitch way instead but I don’t know if I did it right it’s still not working (I started another topic here Custom domain not working..tried everything :(
are you possibly able to take a look if it’s not too much trouble?

1 Like

This tutorial should be updated.
Going to https://fly.io/sites now gives a 404 page.

four-oh-four, maybe lost

It’s giving a 404 because you’re logged out of fly.io. Login to fly.io and visit fly.io/sites again and it should work!

1 Like

@charliea21 One question - is fly.io free?

And could I use this for multiple sites?

fly.io is free if you’re using the Sites option. However, the apps option is not free and you can get billed after you use up all of your free credit.

So if I was to put a markdown site on this, would it be free?

I’m still getting a 404 even after signing in.
I also had already had a site on fly.io and it’s now returning a “Not Found”. (discord.dankzone.xyz)

Okay, that’s strange! @charliea21, I’m also getting a 404 as well.

My worst fears have been confirmed. Fly.io has officially shutdown Fly.io sites even for signed in users(just like how libraries get deprecated). Our fly.io dashboard sites continue to work, but I think they will shut down those next.

By fly.io dashboard sites I mean sites made using this tutorial not ones using the built in custom domains feature in tools.

R.I.P Magical Dashboard 2020
Press heart if you want to pay respects

2 Likes

Maybe I’ll try emailing fly.io and I’ll let you guys know what is gonna happen!

2 Likes

Thank you very much…it would help a lot

As for Glitch users trying to add new custom domains through this tutorial, here is a new tutorial as of January 2020 by @jenn: https://fly-io-domain-setup.glitch.me/

Do we have to pay? I hope not otherwise we might have to avoid fly.io

No, I think fly.io/dashboard/apps is free!

They must have merged the apps and sites together. Horray! Hostnames is a new option I belive. I openned a older app and didn’t see the hostnames tab pop up.
Sadly we’ve lost control over our old fly.io/site style apps

1 Like

I can’t add hostnames because Fly sends me an error that says glitch.me is owned by some other org (Glitch, Inc.). So, that’s means I only use Fly when going to Tools -> Custom Domains and follow prompts?

Are you following the tutorial here?

Hey all,

Fly.io apps do cost. However, you receive $15/month of free credit. As long as you don’t go over this limit you won’t be charged.

You are also billed on bandwidth usage and CPU usage.

See this page for more information.

:wave:

1 Like

So this tutorial isn’t valid any more?

I forgot on adding backends. Reviewing things…

1 Like

The tutorial still works. However, I’m going to rewrite this tutorial to an updated version.

3 Likes

Hey everyone,
I’m going to share some new things I discovered with fly the other day. First of all, you might have noticied fly.io got a website update. I noticied a typo on the sign in page where the placeholder says “Create a password”.

.
Ok that was just for fun. Here’s the real information I found. When I created a new fly.io project I found out this tutorial didn’t work anymore because instead of seeing
this sidebar the new projects will get this
I’ve looked around and I haven’t noticied any way to add glitch projects. However I did find an advertisment that allowed you to configure stuff for heroku. which is still not free.
Fly.io might stop offering custom domains for glitch.me or maybe a new interface is being developed. However I think the custom domains feature in the glitch editor will still work but this requires at least two thanks.

And I sent an email, in fact, I sent two emails about fly.io/sites but they haven’t responded yet! Can someone else try?

I had sent an email about 12 hours ago but there was no reply either.

I can create and manage sites fine. You need to go to fly.io/sites, add a site or edit one and you can get access to the backend section fine.

The thing is that the website shows 404 error and it’s impossible to access it

image

You need to be logged into your fly.io account first.

I’m logged into my fly.io account, and it shows that.

Fly.io always seems to be giving people trouble so I would recommend just using Glitch’s build in domain system.

We know this is an important feature used by many of you; so I wanted to jump in to acknowledge the changes at fly.io.

This does mean that the guide we built and provided to some of you in the past may not match the current recommended flow.

Regardless, you should still be able to link a custom domain with your project. If you need help doing this, you can ask for help in the forum or send a message to [email protected].

Yeah, at the momment the website is sort of broken, like the sign up link takes you to the docs and the button positioning sorta broke, but I can at least login

Thank you for the amazing tutorial!

https://fly.io/docs/apps/cdn/index.html
I found this today. However I think you still have to pay but I think fly offers a limited free tier

hey @tasha i already used this method to get glitch project on a domain name,
today i wanted to check that, and unfortunatly the https://fly.io/sites doesn’t work for me and it give me an four oh four error message even i’m logged in so can you suggest any solutions ?
Thanks !

You can always use the built in domain system.

hey ! @RiversideRocks i already linked my project i nedd to manage some settings

I think the four oh four page comes up when you are not signed in.

@RiversideRocks i’m already signed in

Hmm. In that case you should contact fly.io. I’m not sure if that page is deprecated.

thanks ! is the page working for you ?
i already sent two email but got no answer .

Same here. I signed and sent 2 emails as well but they never replied. But my domains connected through fly.io still works!

Hi there everyone! I posted this on another thread, but I think it would be useful to be here since this is the most popular forum topic here (according to the popular section of the forum) and people have been unable to get a response from fly.io until now!

Unfortunately, fly.io removed the functionality in their service that allowed for custom domains with Glitch, the CDN. I emailed them asking if there was another way to access it and Kurt replied this:

There seems to be no other way, except getting 2 thanks
Sorry about that,
Eddie
P.S. That’s the full email - I didn’t cut it :joy:

2 Likes

But custom domains previously made using fly.io still work, because khaleelgibran.com is configured via fly.io and it still works.

1 Like