Sign inSign up

momar/redirect

By momar

•Updated over 7 years ago

a simple tool built to redirect http requests in a 5MB docker image

Image
0

377

momar/redirect repository overview

⁠redirect

a simple tool built to redirect http requests in a 5MB docker image

⁠Usage

⁠As a binary
go get github.com/moqmar/redirect
TO=https://example.org PERMANENT=1 PREFIX=/home/ redirect
⁠With Docker
docker run -d -p 8080:80 -e "TO=https://example.org" -e "PERMANENT=1" -e "PREFIX=/home/" momar/redirect

This will redirect e.g. http://example.com/home/whatever.txt⁠ to https://example.com/whatever.txt⁠

⁠Environment

VariableDescription
TORedirection target/prefix. Required.
PERMANENTUse 301 Moved Permanently instead of 302 Found if this is set to something other than an empty string, 0, false or no.
PREFIXPrefix regular expression to remove from the path - a leading slash is required, a trailing slash is recommended in most cases. To completely ignore the path, set this to .* - the default behaviour is to keep the full path.
HOST/PORTThe hostname and port to listen on.

⁠Examples

EnvironmentRequestTarget
TO=https://example.org/hello PERMANENT=1 PREFIX=/world/http://example.com/world/test⁠301 https://example.org/hello/test⁠
TO=https://example.org/hello PERMANENT=1 PREFIX=/world/http://example.com/whatever/test⁠301 https://example.org/hello/whatever/test⁠
TO=https://example.org/hello PERMANENT=1 PREFIX=/[^/]*/http://example.com/whatever/test⁠301 https://example.org/hello/test⁠
TO=https://example.org/hello PERMANENT=1 PREFIX=/worldhttp://example.com/worldtest⁠301 https://example.org/hello/test⁠
TO=https://example.org/hello PERMANENT=0http://example.com/whatever/test⁠302 https://example.org/hello/whatever/test⁠
TO=https://example.org/hello PERMANENT=0 PREFIX=.*http://example.com/whatever/test⁠302 https://example.org/hello⁠

Tag summary

Content type

Image

Digest

Size

2.2 MB

Last updated

over 7 years ago

docker pull momar/redirect