-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Docker Compose example with Haproxy and an echo server.
- Loading branch information
Showing
7 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.dockerignore | ||
.git | ||
.github | ||
.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM golang:1.21 AS builder | ||
RUN apt-get update && apt-get install -y iptables iproute2 && apt-get clean | ||
WORKDIR /app/src/go-mmproxy | ||
COPY . . | ||
RUN CGO_ENABLED=0 go build -v | ||
ENTRYPOINT ["sh", "-x", "docker-example/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM ubuntu | ||
RUN apt-get update && apt-get install -y ncat iproute2 tcpdump inetutils-ping iptables && apt-get clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
services: | ||
echo: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.echo | ||
command: ip route replace default via 10.5.5.3 && ncat -kvnl -e /bin/cat 0.0.0.0 9000 | ||
cap_add: [ NET_ADMIN ] | ||
networks: | ||
backend: | ||
ipv4_address: 10.5.5.2 | ||
|
||
go-mmproxy: | ||
build: | ||
context: ../ | ||
dockerfile: docker-example/Dockerfile | ||
command: ./go-mmproxy -l 0.0.0.0:1234 -4 10.5.5.2:9000 -p tcp -v 2 -mark 123 | ||
privileged: true | ||
networks: | ||
backend: | ||
ipv4_address: 10.5.5.3 | ||
default: | ||
|
||
|
||
haproxy: | ||
image: haproxy:2.9 | ||
ports: [ 8000:8000 ] | ||
volumes: | ||
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg | ||
|
||
networks: | ||
backend: | ||
ipam: | ||
config: | ||
- subnet: 10.5.5.0/24 | ||
gateway: 10.5.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
echo 1 > /proc/sys/net/ipv4/conf/all/route_localnet | ||
|
||
# Outgoing packets | ||
iptables -t mangle -A OUTPUT -m mark --mark 123 -j CONNMARK --save-mark | ||
iptables -t mangle -A OUTPUT -m mark --mark 123 -j MARK --set-mark 0 | ||
# Incoming packets | ||
iptables -t mangle -A PREROUTING -m connmark --mark 123 -j CONNMARK --restore-mark | ||
|
||
ip rule add fwmark 123 lookup 100 | ||
ip route add local 0.0.0.0/0 dev lo table 100 | ||
|
||
env "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
frontend myfrontend | ||
bind :8000 | ||
default_backend mybackend | ||
|
||
backend mybackend | ||
balance roundrobin | ||
server go-mmproxy-v1 go-mmproxy:1234 send-proxy |