Skip to content

twopow/srd

Repository files navigation

Simple Redirect Daemon (SRD)

SRD is a tiny HTTP service that turns DNS TXT records into URL redirects. Configure redirects where your DNS already lives. No accounts or control panel - DNS is the source of truth.

Quick Start

This quickstart uses the hosted SRD service, though you're welcome to deploy your own.

  1. Point your domain to the SRD service IP.
    blog.example.com.   IN CNAME   in.srd.sh
  1. Add a TXT record at _srd. specifying the destination URL.
    _srd.blog.example.com.   IN TXT   "v=srd1; dest=https://newblog.example.net"
  1. Now hit https://blog.example.com and you should be redirected to https://newblog.example.net.
    # Check TXT record
    dig +short TXT _srd.blog.example.com

    # Test redirect (look for Location header)
    curl -I https://blog.example.com

Now requests to https://blog.example.com will redirect to https://newblog.example.net.

Note: root domains are supported in the same way. For example, to redirect example.com, configure:

    example.com.   IN A     34.56.76.181
    _srd.example.com.   IN TXT   "v=srd1; dest=https://hello.example.net"

The _srd record format

The _srd record is a TXT record that contains the redirect configuration. Fields are semicolon-separated. Below is a table of the allowed fields:

Field Description Required
v=srd1 The version of the SRD record Yes
dest The destination URL for the redirect Yes
code The HTTP status code for the redirect. Allowed values are 301, 302, 307, 308. Default is 302. No
route set to preserve to preserve the original URL Path and Query String in the redirect No
referer set to none, host, or full to control the Referer header for the redirect. full is the full referring URL, host is the hostname of the referring URL, and none is no Referer header. Default is host. No

Examples:

    _srd.example.com.   IN TXT   "v=srd1; dest=https://example.net"
    _srd.example.com.   IN TXT   "v=srd1; dest=https://example.net/hello/world"
    _srd.example.com.   IN TXT   "v=srd1; dest=https://example.net; code=301"
    _srd.example.com.   IN TXT   "v=srd1; dest=https://example.net; route=preserve"
    _srd.example.com.   IN TXT   "v=srd1; dest=https://example.net; route=preserve; code=307"
    _srd.example.com.   IN TXT   "v=srd1; dest=https://example.net; route=preserve; referer=none"

How it works

  1. When a request comes in for example.com, SRD looks up TXT records for _srd.example.com
  2. If a valid redirect record is found, SRD redirects the request to the specified URL
  3. Records are cached based on the configured TTL

Troubleshooting

  • dig doesn’t show the TXT record → Wait for DNS propagation or lower the DNS TTL while testing.
  • curl -I shows no Location header → Confirm the _srd. record exists and contains v=srd1; dest=....
  • Redirect loop → Make sure dest isn’t pointing back to the same host.
  • Behind a proxy/CDN → Verify it forwards to SRD unmodified and the client hits SRD for example.com.

Using SRD

Hosted for you

SRD provides a hosted service for you to use, free of charge. You can use the hosted SRD by pointing your domain at the SRD Service CNAME: in.srd.sh, or the SRD Service Static IPv4: 34.56.76.181.

Using the hosted SRD Service is as simple as configuring your records and the corresponding _srd.<host> TXT record. No accounts or control panel - DNS is the source of truth.

Record Value Notes
CNAME in.srd.sh use for subdomains or root domains with CNAME Flattening support.
A 34.56.76.181 use for root domains.
blog.example.com.        IN CNAME   in.srd.sh
_srd.blog.example.com.   IN TXT     "v=srd1; dest=https://newblog.example.net"

Deploy your own

Deploy SRD anywhere you can run a small HTTP service. Open the listening port and put it behind your preferred load balancer or reverse proxy.

Configuration can be done via config.yaml file, command line flags or environment variables. Refer to config.example.yaml for an example start configuration file.

# example of running srd locally
go run main.go serve --server.host 127.0.0.1 --server.port 8080

Caddy Helper

When deploying SRD behind a Caddy server, you can use CaddyHelper to support on-demand TLS issuance. CaddyHelper is a lightweight HTTP service that runs alongside SRD. Before allowing Caddy to issue a certificate, it verifies that the domain is properly configured in SRD by resolving the domain through SRD and confirming a successful redirect response.

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages