domain-forward/README.md

53 lines
2.2 KiB
Markdown
Raw Normal View History

2023-12-21 10:17:40 +01:00
# Domain Forward
2021-09-21 18:45:31 +07:00
The [service](https://hosterra.eu/projects/public/forwarder.php) to forward domains using HTTP(s) redirects via Hosterra DoH.
2023-12-21 10:17:40 +01:00
2024-03-08 19:26:17 +01:00
#### Example scenarios:
2021-08-22 14:37:21 +07:00
2023-04-24 08:17:25 +07:00
+ Forward non-www to www domains or vice versa
+ Forward old domains to new domains
2024-03-08 19:26:17 +01:00
+ Forward "parked" domains to a bid platform
+ Forward you own domain to your LinkedIn page
+ …
2021-08-22 14:37:21 +07:00
2024-03-08 19:26:17 +01:00
#### How does it works?
2021-08-22 14:37:21 +07:00
2023-12-21 10:17:40 +01:00
+ Point your domain to Hosterra using CNAME or A/AAAA records
2021-08-22 14:37:21 +07:00
+ Tell us where to forward using TXT records
2023-12-21 10:17:40 +01:00
+ We handle redirection and HTTPS certificates for you
2021-08-22 14:37:21 +07:00
## Get Started
To forward from `www.old.com` to `old.com`, add these records to your DNS:
```
2024-03-08 19:26:17 +01:00
www.old.com. IN CNAME fwd.hosterra.tech
_forward.www.old.com. IN TXT forward-to=https://old.com/*
2021-08-22 14:37:21 +07:00
```
2023-12-21 10:17:40 +01:00
Because CNAME can't be used in apex domains, you can use A/AAAA records.
2021-08-22 14:37:21 +07:00
To forward from `old.com` to `new.net`, add these records to your DNS:
```
2024-03-08 19:26:17 +01:00
old.com. IN A 51.159.188.120
old.com. IN AAAA 2001:bc8:1210:656:dc00:ff:fe26:bfdd
_forward.old.com. IN TXT forward-to=https://new.net/*
2021-08-22 14:37:21 +07:00
```
2024-03-08 19:26:17 +01:00
The star `*` at the end tells us that the remaining URL path is also forwarded to the destination URL. If you want to forward to a unique url, just omit this star.
2022-01-03 15:10:34 +07:00
2024-03-08 19:26:17 +01:00
> If you use Cloudflare or any DNS which supports [CNAME Flattening](https://blog.cloudflare.com/introducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root/), you still can use CNAME records pointing to `fwd.hosterra.tech`. It is recommended to use CNAME records rather than A/AAAA records.
2022-01-03 15:10:34 +07:00
You can choose the type of redirection you want to use by declaring the `http-status` value:
```
2024-03-08 19:26:17 +01:00
www.old.com. IN CNAME fwd.hosterra.tech
_forward.www.old.com. IN TXT http-status=302;forward-to=https://new.com/*
```
2023-12-21 10:17:40 +01:00
> HTTP status codes 301, 302, 303, 307 and 308 are supported. By default it's 301, which is permanent redirection.
2021-08-22 14:37:21 +07:00
2022-08-16 17:32:01 +07:00
## Credits
2023-12-21 14:02:01 +01:00
This software is based on the invaluable work from [Wildan M](https://github.com/willnode/forward-domain) and [BYU Internet Measurement and Anti-Abuse Lab](https://github.com/byu-imaal/dohjs). Endless thanks to them and all the contributors to these two projects.