/*
 * Update target on line 27
 * Run `go build BasicHttpRedirect.go`
 * Move resulting binary to target system
 * Allow port 80 using  `setcap CAP_NET_BIND_SERVICE=+eip <Path to Binary>`
 * Systemd Service Example
[Unit]
Description=Redirect port 80 to target app
After=network.target

[Service]
Type=simple
User=<user>
ExecStart=/<Path to Binary>
Restart=on-failure

[Install]
WantedBy=multi-user.target

*/

package main

import ("net/http")

func redirect(w http.ResponseWriter, r *http.Request) {
    http.Redirect(w, r, "http://Target:Port", 302)
}

func main() {
    http.HandleFunc("/", redirect)
    http.ListenAndServe(":80", nil)
}
