Skip to content

Redirect to urls from a gist with a hostfile. Ready for serverless and Containers

License

Notifications You must be signed in to change notification settings

NiklasMerz/gistdirect

Repository files navigation

gistdirect

Gistdirect is a simple URL redirection service / URL shortener.

Imagine bitly.com or goo.gl and your hosts file combined

Run on Google Cloud

Create a Github Gist or just any plain file hosted somewhere. Gistdirect will grap that file and redirect the alias to the full url.

Sample "host" file:

gh https://github.com

Test File

The URL to the file is provided as an environment variable: GIST_URL. Make sure to provide an URL that is a raw textfile. If you use a GitHub Gist click on the raw button before grabbing the URL like https://gist.githubusercontent.com/NiklasMerz/a9b5905f742b5863197a0af0465a39f6/raw/.

It is a simple Go function which is easy to run on any serverless platform. You can also run the binary somewhere and it will listen on port 8080. Executables are avaible from releases.

I got it running with Google Cloud Functions and Firebase hosting. You can deploy the function from "function.go" via the web interface or gcloud CLI. Firebase can be used to assign a custom domain to the function. Firebase CLI and the "firebase.json" file help you to assing the function to the root of the domain.

Using the Dockerfile

Gistdirect is on Docker Hub so you can just run:

docker run -p 8080:8080 -e GIST_URL='https://gist.github.com/NiklasMerz/a9b5905f742b5863197a0af0465a39f6/raw/' niklasmerz/gistdirect

About

Redirect to urls from a gist with a hostfile. Ready for serverless and Containers

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published