Abstract

Serve an installation script from a personal domain. Point your registrar nameservers to Cloudflare, create a proxied placeholder DNS record, and configure Cloudflare Redirect Rules to send requests to your script on GitHub.

Note

I use Hostinger as my domain registrar, so the nameserver diagram below shows the Hostinger interface. The same step works in any other registrar.

What You Are Going to Get ↑

At the end of this guide, you will have a short URL on your own domain, such as https://recado.vieitesss.eu/install, that serves your installation script from GitHub without running a server of your own. You can also redirect the root of the subdomain (https://recado.vieitesss.eu) to the project repository.

In the following diagram, you can see how the finished setup works:

A terminal or browser requests recado.vieitesss.eu, Cloudflare receives the request through its proxied DNS record and Redirect Rules, and returns an HTTP 302 redirect sending /install to the latest install.sh release on GitHub and / to the vieitesss/recado GitHub repository Terminal orBrowserCloudflareDNS + Redirect RulesGitHub Releaseinstall.shGitHub Repositoryvieitesss/recadorecado.vieitesss.eu/install (302)/ (302)

A request from your terminal or browser goes to recado.vieitesss.eu. Cloudflare intercepts it through a proxied DNS record and checks your Redirect Rules. Requests to /install receive a 302 redirect to install.sh on GitHub Releases, and requests to / receive a 302 redirect to the GitHub repository.

Prerequisites ↑

You need the following before starting:

Connect Your Domain to Cloudflare ↑

Before creating DNS records or Redirect Rules, Cloudflare needs to manage the DNS for your domain.

  1. Access the Cloudflare Dashboard (opens in a new tab) and add your domain to your account.
  2. Copy the two nameservers Cloudflare assigns to your domain (for example, kia.ns.cloudflare.com and max.ns.cloudflare.com).
  3. Open your domain registrar settings and replace the default nameservers with the ones Cloudflare gave you.

In the following diagram, you can see how the nameserver settings look in Hostinger:

Hostinger nameserver settings showing the Change nameservers radio option selected with kia.ns.cloudflare.com and max.ns.cloudflare.com entered in the first two fields kia.ns.cloudflare.commax.ns.cloudflare.comHostinger nameserversChange nameservers

Once the nameserver change propagates, open Domains > Overview in the Cloudflare Dashboard (opens in a new tab) and select the domain you want to make the script accessible from.

Create a DNS Record ↑

Within the domain you have already selected, you are going to create a DNS record for the subdomain that will serve the script. In my case, I use recado.vieitesss.eu.

  1. Open the DNS records section and click Add Record.
  2. Select AAAA as the record type. You can use an A record as well if you prefer IPv4.
  3. Enter the subdomain name in the Name field (for example, recado).
  4. Enter 100:: as the IPv6 address (or a reserved IPv4 placeholder such as 192.0.2.1 if you chose an A record).
  5. Keep the proxy status enabled (Proxied) and save the record.

Note

100:: is a standard discard-only IPv6 placeholder, not a real server (and 192.0.2.1 is the IPv4 placeholder Cloudflare recommends from the 192.0.2.0/24 reserved documentation block). Cloudflare is going to redirect every request before trying to connect to that IP address, so you do not need a real server IP here.

When you create the record, Cloudflare asks if it should be proxied, with the following two options:

In the following diagram, you can see both paths when you request recado.vieitesss.eu:

You request recado.vieitesss.eu, Cloudflare checks whether the DNS record is proxied, the yes branch routes through Cloudflare public IPs so Redirect Rules run and return HTTP 302 to GitHub, and the no branch sends traffic directly to 100:: with no Redirect Rules Userrecado.vieitesss.euProxied?Cloudflarepublic IPsDirect to 100::No Redirect RulesRedirect Rules runHTTP 302 to GitHubyesnoCloudflare

Create the Redirect Rules ↑

Now that the DNS record is ready, the next step is to redirect requests from your subdomain to the hosted script. This is how I configured my rules for recado.vieitesss.eu, with /install returning the script and the root URL redirecting to the repository. You can organize the paths however you want, for example pointing the root URL directly to your installation script.

The Cloudflare Dashboard uses the following labels and fields:

  1. Open Rules > Redirect Rules and click Create rule.

  2. Create the first rule for the installation script using the following settings, then click Deploy:

    text
    Rule name:    recado install script
    Match:        Custom filter expression
    Expression:   (http.host eq "recado.vieitesss.eu" and http.request.uri.path eq "/install")
    Type:         Static
    URL:          https://github.com/vieitesss/recado/releases/latest/download/install.sh
    Status code:  302
    
  3. Create a second rule for the repository fallback using the following settings, and click Deploy again:

    text
    Rule name:    recado repository
    Match:        Custom filter expression
    Expression:   (http.host eq "recado.vieitesss.eu")
    Type:         Static
    URL:          https://github.com/vieitesss/recado
    Status code:  302
    

Important

The first matching rule wins, so the order of these rules matters. You want requests to /install to reach the script instead of the repository, so you have to place the /install rule before the general subdomain rule.

When a request matches one of these rules, Cloudflare returns an HTTP 302 response pointing to GitHub, and it never contacts the 100:: placeholder.

Run the Installation Script ↑

Now that both the DNS record and the Redirect Rules are live, you can download and run the installation script using the following command:

shell
# -f fails on HTTP errors
# -s hides progress
# -S shows errors
# -L follows the 302 redirect
curl -fsSL https://recado.vieitesss.eu/install | sh

Warning

Always include -L when fetching the script with curl. Without it, curl stops at the 302 response from Cloudflare and never follows the redirect to GitHub.