File tree 8 files changed +89
-2
lines changed
e2e/send-proxy-protocol/config
8 files changed +89
-2
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,8 @@ docker-build:
175
175
# - docker image tag $CI_REGISTRY_GO/golang:$GO_VERSION-alpine golang:$GO_VERSION-alpine
176
176
- docker pull -q $CI_REGISTRY_GO/haproxytech/http-echo:latest
177
177
- docker image tag $CI_REGISTRY_GO/haproxytech/http-echo:latest haproxytech/http-echo:latest
178
+ - docker pull -q $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest
179
+ - docker image tag $CI_REGISTRY_GO/haproxytech/proxy-protocol:latest haproxytech/proxy-protocol:latest
178
180
- wget -nv -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND}/kind-linux-amd64
179
181
- chmod +x /usr/local/bin/kind
180
182
- 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 40
40
printf %80s | tr " " " =" ; echo " "
41
41
if [ -n " ${GITLAB_CI} " ]; then
42
42
echo " haproxytech/http-echo:latest pulled from CI registry"
43
+ echo " haproxytech/proxy-protocol:latest pulled from CI registry"
43
44
else
44
45
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
45
47
fi
46
48
echo " 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
48
52
49
53
printf %80s | tr " " " =" ; echo " "
50
54
echo " Create HAProxy namespace ..."
Original file line number Diff line number Diff line change 14
14
spec:
15
15
containers:
16
16
- name: http-echo
17
- image: 'quay.io/prometherion/proxy-protocol-app:latest'
17
+ image: 'haproxytech/proxy-protocol:latest'
18
+ imagePullPolicy: IfNotPresent
18
19
ports:
19
20
- name: http
20
21
containerPort: 8080
Original file line number Diff line number Diff line change
1
+ FROM golang:1.22-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.22.0
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