Skip to content

Simple web server to redirect(with HTTP 302) incoming GET requests to a domain based on geoip

License

Notifications You must be signed in to change notification settings

vsly-ru/go-geo-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple web server to redirect(with HTTP 302) incoming GET requests to a domain based on geoip

Resources

License

Stars

Watchers

Forks

Packages

No packages published