Redirect to a new destination based on CNAME records
466
The redirect service allows you to configure a domain to automatically redirect to a new destination based on CNAME records. By adding a CNAME record to your DNS, you can specify the target domain for redirection and indicate the type of HTTP status code to be used.
/etc/resolv.conf or overridden via an environment variable.docker run -d \
-e REDIRECT_DOMAIN_301=redirect.example.com \
-p 80:80 -p 443:443 \
-v certs:/var/app/certs \
jasny/dns-redirect
The service uses environment variables to determine which domains to redirect and with which HTTP status codes. The following environment variables are supported:
REDIRECT_DOMAIN_301: Domain suffix to be redirected with HTTP status code 301 (Moved Permanently).REDIRECT_DOMAIN_302: Domain suffix to be redirected with HTTP status code 302 (Found).REDIRECT_DOMAIN_303: Domain suffix to be redirected with HTTP status code 303 (See Other).REDIRECT_DOMAIN_307: Domain suffix to be redirected with HTTP status code 307 (Temporary Redirect).REDIRECT_DOMAIN_308: Domain suffix to be redirected with HTTP status code 308 (Permanent Redirect).Note: At least one of the
REDIRECT_DOMAIN_environment variables must be defined, or the service will exit with an error.
DNS_CONFIG_FILE: Path to the DNS configuration file (default: /etc/resolv.conf).CACHE_DNS: Whether to cache DNS lookups (default: false).HTTP_PORT: Port on which the service listens for incoming HTTP requests (default: 80).HTTPS_PORT: Port on which the service listens for incoming HTTPS requests (default: 443).80 and handles incoming HTTP requests and port 443 for HTTPS requests.example.com).http or https) is preserved from the original request.The redirect service will not modify the schema (http or https) of the request. For HTTPS, a certificate is automatically obtained using Let's Encrypt on the first request.
foo.example.com that points to bar.example.net.permanent-redirect.com.REDIRECT_DOMAIN_301="permanent-redirect.com" is set, and the CNAME matches, the service will remove .permanent-redirect.com and redirect foo.example.com to bar.example.net using a 301 Moved Permanently status code.The source code is available under the MIT license at jasny/dns-redirect on GitHub.
Content type
Image
Digest
sha256:f0a77eaac…
Size
11.2 MB
Last updated
11 months ago
docker pull jasny/dns-redirect