Rust service for redirecting based on a _redirect TXT record.
If you just bought a domain but have not set up a webserver yet, you can use 301.systems for redirecting your domain. Some registrars can do this for you, but you can use 301.systems if your registrar does not.
-
If your dns provider supports CNAME records for a root domain, or you want to set up a subdomain, make a CNAME for
301.systems
. Otherwise use an A record that points to78.46.103.16
. You can also create an AAAA record with this ipv6 address:2a01:4f8:120:9316::3
. -
Set up a TXT record for _redirect.yourdomain.tld. The TXT record should contain a valid URL to the site that you want to be redirected to. For example:
$ dig TXT _redirect.301.systems
; <<>> DiG 9.9.7-P3 <<>> TXT _redirect.301.systems
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51808
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;_redirect.301.systems. IN TXT
;; ANSWER SECTION:
_redirect.301.systems. 3600 IN TXT "https://github.com/pingiun/Redirector"
;; Query time: 1104 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Wed Apr 11 16:24:26 CEST 2018
;; MSG SIZE rcvd: 100
You should now be redirected when you visit yourdomain.tld.
If you want to host the rust service yourself you can take these steps:
- Clone this repository (
git clone https://github.com/pingiun/Redirector
) - Build the project with
cargo build --release
or with docker:docker build -t redirector .
- When running the program, supply the
LISTEN_ADDR
environment variable, for example:
LISTEN_ADDR=localhost:8080 RUST_LOG=redirector=info target/release/redirector
or in docker (example uses the docker hub version):
docker run -e LISTEN_ADDR=0.0.0.0:80 -p 80:80 -d pingiun/redirector
If you want to run on ipv6 as well (or any other address), you can supply the LISTEN_ADDR_6
environment variable.
This project has supplied a kubernetes deployment to run redirector with 3 replicas. You can change the deploy.yaml file to your needs and create the deployment with kubectl create -f deploy.yaml
.