DomainRedirect/Readme.md
2024-02-20 14:45:12 -08:00

1.3 KiB

DomainRedirect

This is a simple http redirect service. It is designed to be used with a domain that is not the primary domain for a website. For example, if you have a website at example.com and you want to redirect example.net to example.com, you can use this service.

Features

  • Redirects all requests other than /health to whatever is specified in the REDIRECT_TARGET environment variable.
  • Health check endpoint at /health that returns a 200 status code.

Limitations

  • Paths are not preserved. For example, if a user goes to example.net/foo, they will be redirected to the REDIRECT_TARGET such as example.com.

Usage

This is not compatible with Node or Deno. It is written to be run with Bun

Run with Bun

REDIRECT_TARGET="https://example.com/" bun run index.js

Run with Docker

  1. Build the image
docker build -t domainredirect .
  1. Run the image
docker run -p 8080:8080 -e REDIRECT_TARGET="https://example.com/" domainredirect

Note: If you are building on Apple Silicon and deploying to x86 like me, you will need to build for a different platform

Run with Nomad on Docker

Check out my homelab implementation.