Skip to content

Latest commit

 

History

History
45 lines (37 loc) · 1.87 KB

README.md

File metadata and controls

45 lines (37 loc) · 1.87 KB

go-geo-redirect

A simple redirect app written in go. It listens for HTTP requests with any URL. When one occurs, it determines geoip data of the original IP of the request. Based on the country from geoip response, it redirects the request(using HTTP 302 code) to the same URL and query of a preconfigured domain, based on the detected country. If no ip was recognized, geoip fails or country not in the config, it will always redirect to the default domain (from the config).

Config

When the server is launched, it looks for config.toml next to it.

Example config:

[redirects]
default = "https://example.com"
DE = "https://de.example.com"
IT = "https://it.example.com"

Example redirects

If you are using the config above and run this app on a domain example.org, here is some example redirects:

Building

Build for your current platform

go build

Build for linux amd64 (see supported GOOS and GOARCH values here)

env GOOS=linux GOARCH=amd64 go build -o webhook_linux_amd64

Build for all release platforms

./scripts/build-all.sh