diff --git a/flake.nix b/flake.nix index 0207fb1..dbf316a 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ in { ts-reverse-proxy = pkgs.buildGoModule { pname = "ts-reverse-proxy"; - version = "v0.0.0"; + version = "v0.0.1"; src = ./.; vendorSha256 = "sha256-QcuL7qjNTloLBYnT2pZtYDZlj2/qm8sNS7EUVBbCp7U="; diff --git a/main.go b/main.go index 7a540af..990ad58 100644 --- a/main.go +++ b/main.go @@ -8,11 +8,24 @@ import ( "net/http" "net/http/httputil" "net/url" + "time" "tailscale.com/client/tailscale" "tailscale.com/tsnet" ) +func httpLog(r *http.Request) { + n := time.Now() + fmt.Printf("%s (%s) [%s] \"%s %s\" %03d\n", + r.RemoteAddr, + n.Format(time.RFC822Z), + r.Method, + r.URL.Path, + r.Proto, + r.ContentLength, + ) +} + func main() { sName := flag.String("name", "", "server name we will be reverse proxying for") cIP := flag.String("ip", "127.0.0.1", "ip address to reverse proxy to") @@ -43,6 +56,7 @@ func main() { req.Header.Add("X-Origin-Host", rpURL.Host) req.URL.Scheme = rpURL.Scheme req.URL.Host = rpURL.Host + httpLog(req) }} mux := http.NewServeMux()