I recently needed to perform some simple domain redirects, and surprise - there is a minimal docker container that is perfect for the job.

docker run -d --restart=always \
 -e REDIRECT_TARGET=https://domaintoredirect.biz \
 -e VIRTUAL_HOST=www.someotherdomain.com,someotherdomain.com \
 -e LETSENCRYPT_HOST=www.someotherdomain.com,someotherdomain.com \
 --name=domaintoredirect-biz -p 8080:80 morbz/docker-web-redirect

This works a treat, but does require a few things done first:

  1. Change the DNS records for www.someotherdomain.com and someotherdomain.com to point the address for the docker server.
  2. Setup nginx-proxy - https://github.com/nginx-proxy/nginx-proxy
  3. Setup nginx-proxy-companion - https://github.com/nginx-proxy/docker-letsencrypt-nginx-proxy-companion
  4. Now create the container with your customised version of the command above and presto.
  5. Redirection happens.