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 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:
- A personal domain registered with a domain registrar.
- A Cloudflare account.
- An installation script hosted at a public URL, such as a GitHub release.
Connect Your Domain to Cloudflare ↑
Before creating DNS records or Redirect Rules, Cloudflare needs to manage the DNS for your domain.
- Access the Cloudflare Dashboard (opens in a new tab) and add your domain to your account.
- Copy the two nameservers Cloudflare assigns to your domain (for example,
kia.ns.cloudflare.comandmax.ns.cloudflare.com). - 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:
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.
- Open the DNS records section and click
Add Record. - Select
AAAAas the record type. You can use anArecord as well if you prefer IPv4. - Enter the subdomain name in the
Namefield (for example,recado). - Enter
100::as the IPv6 address (or a reserved IPv4 placeholder such as192.0.2.1if you chose anArecord). - 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:
- If you say yes, the domain resolves to the public IPs of Cloudflare, so the HTTPS request goes to Cloudflare first and Cloudflare can run your Redirect Rules.
- If you say no, the domain resolves directly to the configured IP
(
100::), so the connection fails and the Redirect Rules of Cloudflare never run.
In the following diagram, you can see both paths when you request
recado.vieitesss.eu:
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:
-
Open
Rules > Redirect Rulesand clickCreate rule. -
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
-
Create a second rule for the repository fallback using the following settings, and click
Deployagain: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:
# -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.