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:
- Change the DNS records for www.someotherdomain.com and someotherdomain.com to point the address for the docker server.
- Setup nginx-proxy - https://github.com/nginx-proxy/nginx-proxy
- Setup nginx-proxy-companion - https://github.com/nginx-proxy/docker-letsencrypt-nginx-proxy-companion
- Now create the container with your customised version of the command above and presto.
- Redirection happens.