File tree Expand file tree Collapse file tree 8 files changed +89
-2
lines changed
e2e/send-proxy-protocol/config Expand file tree Collapse file tree 8 files changed +89
-2
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,8 @@ docker-build:
174174 # - docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
175175 - docker pull -q $CI_REGISTRY_GO/haproxytech/http-echo:latest
176176 - docker image tag $CI_REGISTRY_GO/haproxytech/http-echo:latest haproxytech/http-echo:latest
177+ - docker pull -q $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest
178+ - docker image tag $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest haproxytech/proxy-protocol:latest
177179 - wget -nv -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND}/kind-linux-amd64
178180 - chmod +x /usr/local/bin/kind
179181 - wget -nv -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL}/bin/linux/amd64/kubectl
Original file line number Diff line number Diff line change 4040printf %80s | tr " " " =" ; echo " "
4141if [ -n " ${GITLAB_CI} " ]; then
4242 echo " haproxytech/http-echo:latest pulled from CI registry"
43+ echo " haproxytech/proxy-protocol:latest pulled from CI registry"
4344else
4445 docker build --build-arg TARGETPLATFORM=" linux/amd64" -t haproxytech/http-echo -f deploy/tests/images/http-echo/Dockerfile deploy/tests/images/http-echo
46+ docker build --build-arg TARGETPLATFORM=" linux/amd64" -t haproxytech/proxy-protocol -f deploy/tests/images/proxy-protocol/Dockerfile deploy/tests/images/proxy-protocol
4547fi
4648echo " loading image http-echo in kind"
47- kind load docker-image haproxytech/http-echo:latest --name=$clustername
49+ kind load docker-image haproxytech/http-echo:latest --name=$clustername
50+ echo " loading image proxy-protocol in kind"
51+ kind load docker-image haproxytech/proxy-protocol:latest --name=$clustername
4852
4953printf %80s | tr " " " =" ; echo " "
5054echo " Create HAProxy namespace ..."
Original file line number Diff line number Diff line change 1414 spec:
1515 containers:
1616 - name: http-echo
17- image: 'quay.io/prometherion/proxy-protocol-app:latest'
17+ image: 'haproxytech/proxy-protocol:latest'
18+ imagePullPolicy: IfNotPresent
1819 ports:
1920 - name: http
2021 containerPort: 8080
Original file line number Diff line number Diff line change 1+ FROM golang:1.24-alpine AS builder
2+
3+ COPY *.go /src/
4+ COPY go.mod /src/go.mod
5+ COPY go.sum /src/go.sum
6+
7+ RUN cd /src && go build -o proxy-protocol
8+
9+ FROM alpine:3
10+ WORKDIR /app
11+ COPY --from=builder /src/proxy-protocol .
12+
13+ ENTRYPOINT ["./proxy-protocol" ]
14+ CMD []
Original file line number Diff line number Diff line change 1+ # proxy-protocol
2+
3+ A simple Go web server backed by PROXY Protocol.
4+
5+ ## How to use
6+
7+ ``` bash
8+ docker build -t haproxytech/proxy-protocol -f deploy/tests/images/proxy-protocol/Dockerfile deploy/tests/images/proxy-protocol
9+ docker run -p 8080:8080 --rm -t haproxytech/proxy-protocol
10+ ```
11+
12+ ## Output example
13+
14+ ```
15+ $: curl --haproxy-protocol --http1.1 http://localhost:8080/
16+ hello!
17+ ````
18+
19+ ## Credits
20+
21+ [github.com/pires/go-proxyproto](https://github.com/pires/go-proxyproto)
Original file line number Diff line number Diff line change 1+ module proxy-protocol
2+
3+ go 1.24
4+
5+ require github.com/pires/go-proxyproto v0.8.0
Original file line number Diff line number Diff line change 1+ github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKpXEe0 =
2+ github.com/pires/go-proxyproto v0.8.0 /go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY =
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "net"
6+ "net/http"
7+ "os"
8+
9+ "github.com/pires/go-proxyproto"
10+ )
11+
12+ func main () {
13+ // Create a TCP listener on port 8080
14+ addr := ":8080"
15+ tcpListener , err := net .Listen ("tcp" , addr )
16+ if err != nil {
17+ fmt .Fprintf (os .Stderr , "Error creating TCP listener: %v\n " , err )
18+ os .Exit (1 )
19+ }
20+
21+ // Wrap it with the PROXY protocol listener
22+ proxyListener := & proxyproto.Listener {Listener : tcpListener }
23+
24+ // Ensure the listener is closed on shutdown
25+ defer proxyListener .Close ()
26+
27+ // HTTP handler
28+ http .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
29+ fmt .Fprint (w , "hello!" )
30+ })
31+
32+ // Serve using custom listener
33+ fmt .Printf ("Listening on %s with PROXY protocol support...\n " , addr )
34+ if err := http .Serve (proxyListener , nil ); err != nil {
35+ fmt .Fprintf (os .Stderr , "HTTP server error: %v\n " , err )
36+ os .Exit (1 )
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments