aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-04-06 14:58:53 -0400
committerXe Iaso <me@xeiaso.net>2025-04-06 14:58:53 -0400
commitea8b945a1af8603bbecf2fc2e398c321468bc650 (patch)
tree5afaf9eb6ae887e01ae0dc3c782b550c30400fed /cmd
parent737b2a941a670101d42a9c8fa54052afb1658a83 (diff)
downloadx-ea8b945a1af8603bbecf2fc2e398c321468bc650.tar.xz
x-ea8b945a1af8603bbecf2fc2e398c321468bc650.zip
add reverseproxyd
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/reverseproxyd/main.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/cmd/reverseproxyd/main.go b/cmd/reverseproxyd/main.go
new file mode 100644
index 0000000..964ef38
--- /dev/null
+++ b/cmd/reverseproxyd/main.go
@@ -0,0 +1,38 @@
+package main
+
+import (
+ "flag"
+ "log"
+ "log/slog"
+ "net/http"
+ "net/http/httputil"
+ "net/url"
+
+ "within.website/x/internal"
+)
+
+var (
+ bind = flag.String("bind", ":3004", "port to listen on")
+ proxyTo = flag.String("proxy-to", "http://localhost:5000", "where to reverse proxy to")
+)
+
+func main() {
+ internal.HandleStartup()
+
+ slog.Info("starting",
+ "bind", *bind,
+ "proxy-to", *proxyTo,
+ )
+
+ u, err := url.Parse(*proxyTo)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ log.Fatal(
+ http.ListenAndServe(
+ *bind,
+ httputil.NewSingleHostReverseProxy(u),
+ ),
+ )
+}