Menu

Post image 1
Post image 2
1 / 2
0

Building a Forward Proxy in Go with Middleware and Auth

DEV Community·SalzDevs·18 days ago
#uowQHqzR
Reading 0:00
15s threshold

I’ve been building Groxy , a pre-v1 Go library for creating forward proxy servers. It supports: HTTP forwarding HTTPS CONNECT tunneling middleware blocking/body transforms access logs proxy authentication opt-in HTTPS inspection Minimal proxy proxy , err := groxy . New ( groxy . Config { Addr : "127.0.0.1:8080" , }) if err != nil { log . Fatal ( err ) } log . Fatal ( proxy . Start ()) Enter fullscreen mode Exit fullscreen mode Try it: curl -x http://127.0.0.1:8080 http://example.com curl -x http://127.0.0.1:8080 https://example.com Enter fullscreen mode Exit fullscreen mode Middleware proxy . Use ( groxy . AddRequestHeader ( "X-From-Groxy" , "true" ), groxy . AccessLog ( log . Default ()), ) Enter fullscreen mode Exit fullscreen mode Proxy auth proxy . Use ( groxy . ProxyBasicAuth ( "admin" , os . Getenv ( "PROXY_PASSWORD" ))) Enter fullscreen mode Exit fullscreen mode Or: proxy . Use ( groxy . ProxyBasicAuthFunc ( func ( username , password string ) bool { return users .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More