Using Fastly for logging GitHub Pages traffic?

Hey all!

I want to log traffic, for my own domain, that points to a static site, hosted using GitHub pages.

  • I do not want to use services like google analytics, as my audience is small, or are using ad-blockers.
  • I do not want to host a server, as that is costly and unnecessary.
  • I currently don’t want to do anything other than write simple markdown that gets deployed every commit.

I discussed this problem with an engineer from Fastly at PyCon US, who mentioned this is possible using Fastly, however I have been unable to figure out how this could be done.

So far, I’ve tried pointing my www.domain cname to dualstack.nonssl.global.fastly.net and setting up a cdn, with the host being my www.domain, and the origin being being username.github.io, however github won’t accept it. Bar the fact that it doesn’t feel right.

This blog is suggesting that this is only possible with vercel (and previously logflare.app through the now deprecated cloudflare apps) however that was 3 years ago and am hoping things have changed since then.

Is this achievable with fastly (and could someone point me to resources that would help me do it), or am I better spending my time elsewhere?

Thanks so much!

Hi there!

It sounds like you’re basically trying to set up a CDN service and point your domain at it so that you can use Fastly’s observability features?

I just tried pointing a CDN service (with a Fastly domain rather than my own) at a GitHub pages site and it worked at the *.global.ssl.fastly.net address so the issue might be on the domain side unless something isn’t set up right in your service.

Could you share what happens when you click Test domain in the Domains section of your Fastly service?

When you say GitHub won’t accept it, could you clarify what error you’re seeing?

It sounds like you’re basically trying to set up a CDN service and point your domain at it so that you can use Fastly’s observability features?

I think so, except I was also told that this would be free as I wouldn’t be getting a lot of traffic, but when I go to observability → domains, I can only get a 30 day trial, or be charged $1500 a month at minimum?

Could you share what happens when you click Test domain in the Domains section of your Fastly service?

Last night it used to give an error, however now it resolves properly.

When you say GitHub won’t accept it, could you clarify what error you’re seeing?

The error that I got (and still get) is:

Both www.domain.com and its alternate name are improperly configured

Your site's DNS settings are using a custom subdomain, `www.domain.com`, that is not set up with a correct `CNAME` record. We recommend you change this to a `CNAME` record pointing to `username.github.io`. For more information, see [documentation](https://docs.github.com/articles/setting-up-a-custom-domain-with-github-pages/) (InvalidCNAMEError).

My domain config is as follows:

$ dig www.domain.com +nostats +nocomments +nocmd
;www.domain.com.		IN	A
www.domain.com.	551	IN	CNAME	dualstack.nonssl.global.fastly.net.
dualstack.nonssl.global.fastly.net. 11 IN A	151.101.192.204
dualstack.nonssl.global.fastly.net. 11 IN A	151.101.128.204
dualstack.nonssl.global.fastly.net. 11 IN A	151.101.64.204
dualstack.nonssl.global.fastly.net. 11 IN A	151.101.0.204

OK cool, you definitely don’t need to pay anything, the message you’re seeing is just for a specific observability feature that lets you analyze by domain, but you should be able to see your stats in your service if you open it and select Observability from there, or browse in the Observability section by service.

So the error is just in GitHub and your domain is resolving ok with no errors when you navigate to the site now?

On the GitHub side I’d guess it’s just that you’re pointing the DNS at Fastly rather than GitHub, I am not super familiar with using custom domains for GitHub pages but am not sure if you still need something in the repo to indicate you’re using a custom domain, given that I was able to point a Fastly service at one of mine it’s possible you don’t need that at all but I hesitate to suggest that in case it breaks your setup…

This is a great free setup! Normally I recommend people use Glitch + Fastly for a free site with their own domain but this is a nice option to be able to give too. :tada:

1 Like