Docker-ized Stalwart Email Server with Socks/Proxy Protocol Attempt #557
Replies: 5 comments 11 replies
-
You can use several tcp_stream servers to map each of the ports, see https://github.com/bytedance/g3/blob/master/g3proxy/examples/simple_tcp_stream/g3proxy.yaml. |
Beta Was this translation helpful? Give feedback.
-
I think that is the correct way. I can send the I have only stubbed out the docker compose up
compose.ymlroot@server:~/stalwart# cat compose.yml
my_g3proxy.yml
docker ps
|
Beta Was this translation helpful? Give feedback.
-
I have mocked in all the ports to my I've looked at the SMTP ports: 25, 465, and 587 compose.ymlnetworks:
g3-net:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
services:
g3proxy:
image: g3proxy/comp:g3
build:
context: ./g3
dockerfile: g3proxy/docker/debian.Dockerfile
ports:
- "88:88"
- "80:80"
- "8080:8080"
- "443:443"
- "25:25"
- "587:587"
- "465:465"
- "143:143"
- "993:993"
- "4190:4190"
- "110:110"
- "995:995"
networks:
g3-net:
ipv4_address: 10.5.0.5
volumes:
- .:/g3/
command:
-c /g3/my_g3proxy.yml
stalwart-mail:
image: stalwartlabs/mail-server:latest
hostname: stalwart-mail
container_name: stalwart-mail
networks:
g3-net:
ipv4_address: 10.5.0.8
volumes:
- ./opt:/opt/stalwart-mail my_g3proxy.ymllog: stdout
runtime:
thread_number: 2
controller:
local:
recv_timeout: 30
send_timeout: 1
server:
- name: stwt_http_8080
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:8080"
proxy_pass: "10.5.0.8:8080"
- name: stwt_https_443
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:443"
proxy_pass: "10.5.0.8:443"
- name: stwt_smtp_25
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:25"
proxy_pass: "10.5.0.8:25"
- name: stwt_submission_587
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:587"
proxy_pass: "10.5.0.8:587"
- name: stwt_submission_465
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:465"
proxy_pass: "10.5.0.8:465"
- name: stwt_imap_143
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:143"
proxy_pass: "10.5.0.8:143"
- name: stwt_imaptls_993
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:993"
proxy_pass: "10.5.0.8:993"
- name: stwt_sieve_4190
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:4190"
proxy_pass: "10.5.0.8:4190"
- name: stwt_pop3_110
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:110"
proxy_pass: "10.5.0.8:110"
- name: stwt_pop3s_995
escaper: esc_stwt
type: tcp_stream
listen:
address: "10.5.0.5:995"
proxy_pass: "10.5.0.8:995"
escaper:
- name: esc_stwt
type: direct_fixed
bind_ip: "10.5.0.5"
resolver: default
egress_network_filter:
default: forbid
permit:
- 10.5.0.8
resolver:
- name: default
type: c-ares docker compose uproot@server:~/stalwart# docker compose up
[+] Running 9/9
✔ stalwart-mail Pulled 8.8s
✔ 3815f79548aa Pull complete 5.7s
✔ d05ac034a050 Pull complete 5.7s
✔ 69a176fe4a1f Pull complete 6.8s
✔ ff59faa70d57 Pull complete 7.4s
✔ 13eed8633459 Pull complete 7.6s
✔ 599733dffedd Pull complete 7.6s
✔ 6cc142849f3d Pull complete 7.6s
! g3proxy Warning pull access denied for g3proxy/comp, repository does not ex... 0.9s
[+] Building 697.2s (16/16) FINISHED docker:default
=> [g3proxy internal] load build definition from debian.Dockerfile 0.0s
=> => transferring dockerfile: 658B 0.0s
=> [g3proxy internal] load metadata for docker.io/library/debian:bookworm-slim 0.8s
=> [g3proxy internal] load metadata for docker.io/library/rust:bookworm 1.1s
=> [g3proxy internal] load .dockerignore 0.0s
=> => transferring context: 92B 0.0s
=> [g3proxy builder 1/5] FROM docker.io/library/rust:bookworm@sha256:738ae99a3d75623f41e6882566b4ef37e38 42.3s
=> => resolve docker.io/library/rust:bookworm@sha256:738ae99a3d75623f41e6882566b4ef37e38a9840244a47efd4a0 0.0s
=> => sha256:cdb394ef6c0ddd4d077351c8ccd2d55af621b279730caf26cf113c1e562b8e78 4.36kB / 4.36kB 0.0s
=> => sha256:a492eee5e55976c7d3feecce4c564aaf6f14fb07fdc5019d06f4154eddc93fde 48.48MB / 48.48MB 2.8s
=> => sha256:32b550be6cb62359a0f3a96bc0dc289f8b45d097eaad275887f163c6780b4108 24.06MB / 24.06MB 4.3s
=> => sha256:738ae99a3d75623f41e6882566b4ef37e38a9840244a47efd4a0ca22e9628b88 7.75kB / 7.75kB 0.0s
=> => sha256:479476fa1dec14dfa9ed2dbcaa94cda5ab945e125d45c2d153267cc0135f3b69 1.94kB / 1.94kB 0.0s
=> => sha256:35af2a7690f2b43e7237d1fae8e3f2350dfb25f3249e9cf65121866f9c56c772 64.39MB / 64.39MB 7.2s
=> => sha256:7576b00d9bb10cc967bb5bdeeb3d5fa078ac8800e112aa03ed15ec199662d4f7 211.33MB / 211.33MB 15.2s
=> => extracting sha256:a492eee5e55976c7d3feecce4c564aaf6f14fb07fdc5019d06f4154eddc93fde 5.7s
=> => sha256:d702af6a2b4f14eeed68b29d7e6676c2ac3a68619de372120a67811b71922b59 194.94MB / 194.94MB 17.1s
=> => extracting sha256:32b550be6cb62359a0f3a96bc0dc289f8b45d097eaad275887f163c6780b4108 1.6s
=> => extracting sha256:35af2a7690f2b43e7237d1fae8e3f2350dfb25f3249e9cf65121866f9c56c772 6.1s
=> => extracting sha256:7576b00d9bb10cc967bb5bdeeb3d5fa078ac8800e112aa03ed15ec199662d4f7 15.9s
=> => extracting sha256:d702af6a2b4f14eeed68b29d7e6676c2ac3a68619de372120a67811b71922b59 9.1s
=> [g3proxy internal] load build context 0.4s
=> => transferring context: 8.99MB 0.4s
=> [g3proxy stage-1 1/4] FROM docker.io/library/debian:bookworm-slim@sha256:40b107342c492725bc7aacbe93a49 7.1s
=> => resolve docker.io/library/debian:bookworm-slim@sha256:40b107342c492725bc7aacbe93a49945445191ae36418 0.0s
=> => sha256:44bccdd61bf09a081b1db8c61cf49bfabf30ac7afcc970010137c0ab587b209c 1.02kB / 1.02kB 0.0s
=> => sha256:a916d01f3536e5997c7efefcb146c7b80d355f2a51d86b75ad1a339a0f9582ea 453B / 453B 0.0s
=> => sha256:c29f5b76f736a8b555fd191c48d6581bb918bcd605a7cbcc76205dd6acff3260 28.21MB / 28.21MB 2.9s
=> => sha256:40b107342c492725bc7aacbe93a49945445191ae364184a6d24fedb28172f6f7 8.56kB / 8.56kB 0.0s
=> => extracting sha256:c29f5b76f736a8b555fd191c48d6581bb918bcd605a7cbcc76205dd6acff3260 4.0s
=> [g3proxy stage-1 2/4] RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt 13.4s
=> [g3proxy builder 2/5] WORKDIR /usr/src/g3 1.2s
=> [g3proxy builder 3/5] COPY . . 0.5s
=> [g3proxy builder 4/5] RUN apt-get update && apt-get install -y libclang-dev cmake capnproto 16.4s
=> [g3proxy builder 5/5] RUN cargo build --profile release-lto --no-default-features --features vendor 635.1s
=> [g3proxy stage-1 3/4] COPY --from=builder /usr/src/g3/target/release-lto/g3proxy /usr/bin/g3proxy 0.1s
=> [g3proxy stage-1 4/4] COPY --from=builder /usr/src/g3/target/release-lto/g3proxy-ctl /usr/bin/g3proxy- 0.0s
=> [g3proxy] exporting to image 0.1s
=> => exporting layers 0.1s
=> => writing image sha256:527ce6969fc30a0d242a612f36fad8a0533ad474e2c5c84fe60e030db247d1e9 0.0s
=> => naming to docker.io/g3proxy/comp:g3 0.0s
=> [g3proxy] resolving provenance for metadata file 0.0s
[+] Running 4/4
✔ g3proxy Built 0.0s
✔ Network stalwart_g3-net Created 0.1s
✔ Container stalwart-mail Created 0.1s
✔ Container stalwart-g3proxy-1 Created 0.1s
Attaching to g3proxy-1, stalwart-mail
stalwart-mail | ✅ Configuration file written to /opt/stalwart-mail/etc/config.toml
stalwart-mail | 🔑 Your administrator account is 'xxxxxxxxxxx' with password 'xxxxxxxxxxx'.
g3proxy-1 | Feb 18 04:37:02.860 INFO c_rd_bytes: 87, c_wr_bytes: 2299, client_addr: 97.83.98.141:64324, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:49444, next_peer_addr: 10.5.0.8:8080, pid: 1, r_rd_bytes: 2299, r_wr_bytes: 87, ready_time: 331.863µs, reason: ClosedByClient, server_addr: 10.5.0.ame: stwt_http_8080, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:37:02.796443Z, task_event: finished, task_id: ffc67216edb111ef986ed3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 289.756µs, tcp_connect_tries: 1, total_time: 63.626ms, upstream: 10.5.0.8:8080, closed by client
g3proxy-1 | Feb 18 04:40:54.450 INFO c_rd_bytes: 3845, c_wr_bytes: 322592, client_addr: 97.83.98.1t, t, server_addr: 10.5.0.5:8080, server_name: stwt_http_8080, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:34:58.068074Z, task_event: finished, task_id: b56e682cedb111ef986cd3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 585.354µs, tcp_connect_tries: 1, total_time: 356.382s, upstream: 10.5.0.8:8080, closed by client
g3proxy-1 | Feb 18 04:40:54.450 INFO c_rd_bytes: 801, c_wr_bytes: 68202, client_addr: 97.83.98.141:64314, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:33678, next_peer_addr: 10.5.0.8:8080, pid: 1, r_rd_bytes: 68202, r_wr_bytes: 801, ready_time: 640.998µs, reason: ClosedByClient, server_addr: 10.5.0.5:8080, server_name: stwt_http_8080, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:34:58.057261Z, task_event: finished, task_id: b56cc1cbedb111ef986bd3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 588.740µs, tcp_connect_tries: 1, total_time: 356.393s, upstream: 10.5.0.8:8080, closed by client
g3proxy-1 | Feb 18 04:40:54.450 INFO c_rd_bytes: 2394, c_wr_bytes: 6868118, client_addr: 97.83.98.141:64315, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:33692, next_peer_addr: 10.5.0.8:8080, pid: 1, r_rd_bytes: 6868118, r_wr_bytes: 2394, ready_time: 452.218µs, reason: ClosedByClient, server_addr: 10.5.0.5:8080, server_name: stwt_http_8080, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:34:58.210285Z, task_event: finished, task_id: b5841b42edb111ef986dd3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 403.057µs, tcp_connect_tries: 1, total_time: 356.240s, upstream: 10.5.0.8:8080, closed by client
g3proxy-1 | Feb 18 04:48:23.122 INFO c_rd_bytes: 11, c_wr_bytes: 7, client_addr: 97.83.98.141:62858, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:57852, next_peer_addr: 10.5.0.8:465, pid: 1, r_rd_bytes: 7, r_wr_bytes: 11, ready_time: 518.961µs, reason: ClosedByUpstream, server_addr: 10.5.0.5:465, server_name: stwt_submission_465, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:48:18.907789Z, task_event: finished, task_id: 92c4d989edb311ef9871d3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 477.715µs, tcp_connect_tries: 1, total_time: 4.215s, upstream: 10.5.0.8:465, closed by upstream
g3proxy-1 | Feb 18 04:48:35.315 INFO c_rd_bytes: 12, c_wr_bytes: 7, client_addr: 97.83.98.141:62856, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:41662, next_peer_addr: 10.5.0.8:465, pid: 1, r_rd_bytes: 7, r_wr_bytes: 12, ready_time: 262.666µs, reason: ClosedByUpstream, server_addr: 10.5.0.5:465, server_name: stwt_submission_465, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:48:32.447769Z, task_event: finished, task_id: 9ad6e2faedb311ef9872d3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 222.332µs, tcp_connect_tries: 1, total_time: 2.867s, upstream: 10.5.0.8:465, closed by upstream
g3proxy-1 | Feb 18 04:48:59.525 INFO c_rd_bytes: 21, c_wr_bytes: 7, client_addr: 97.83.98.141:62902, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:49232, next_peer_addr: 10.5.0.8:465, pid: 1, r_rd_bytes: 7, r_wr_bytes: 21, ready_time: 353.986µs, reason: ClosedByUpstream, server_addr: 10.5.0.5:465, server_name: stwt_submission_465, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:48:47.710957Z, task_event: finished, task_id: a3efdd4aedb311ef9873d3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 311.998µs, tcp_connect_tries: 1, total_time: 11.814s, upstream: 10.5.0.8:465, closed by upstream
g3proxy-1 | Feb 18 04:52:10.053 INFO c_rd_bytes: 75, c_wr_bytes: 481, client_addr: 97.83.98.141:62870, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:36064, next_peer_addr: 10.5.0.8:25, pid: 1, r_rd_bytes: 481, r_wr_bytes: 75, ready_time: 484.888µs, reason: ClosedByUpstream, server_addr: 10.5.0.5:25, server_name: stwt_smtp_25, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:45:54.518534Z, task_event: finished, task_id: 3cb4cc3dedb311ef986fd3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 442.059µs, tcp_connect_tries: 1, total_time: 375.535s, upstream: 10.5.0.8:25, closed by upstream
g3proxy-1 | Feb 18 04:52:51.796 INFO c_rd_bytes: 13, c_wr_bytes: 334, client_addr: 97.83.98.141:62864, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:35858, next_peer_addr: 10.5.0.8:587, pid: 1, r_rd_bytes: 334, r_wr_bytes: 13, ready_time: 400.151µs, reason: ClosedByUpstream, server_addr: 10.5.0.5:587, server_name: stwt_submission_587, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:47:41.194116Z, task_event: finished, task_id: 7c4a3328edb311ef9870d3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 363.332µs, tcp_connect_tries: 1, total_time: 310.602s, upstream: 10.5.0.8:587, closed by upstream
g3proxy-1 | Feb 18 04:57:31.349 INFO c_rd_bytes: 449, c_wr_bytes: 1056, client_addr: 97.83.98.141:62922, daemon_name: , escaper: esc_stwt, log_type: Task, next_bind_ip: 10.5.0.5, next_bound_addr: 10.5.0.5:34142, next_peer_addr: 10.5.0.8:465, pid: 1, r_rd_bytes: 1056, r_wr_bytes: 449, ready_time: 353.604µs, reason: ClosedByUpstream, server_addr: 10.5.0.5:465, server_name: stwt_submission_465, server_type: TcpStream, stage: Relaying, start_at: 2025-02-18T04:52:16.023925Z, task_event: finished, task_id: 2019e697edb411ef9874d3e3dc139339, task_type: TcpConnect, tcp_connect_spend: 319.932µs, tcp_connect_tries: 1, total_time: 315.325s, upstream: 10.5.0.8:465, closed by upstream
openssl s_client -connect mail.landingdev.xyz:465 -crlf -ign_eof
|
Beta Was this translation helpful? Give feedback.
-
I'm looking diagnostically at This example successfully pulls a curl -l -vvv https://who.landingdev.xyz:443
docker compose up
compose.yml
my_g3proxy.yml
FILES
docker ps
|
Beta Was this translation helpful? Give feedback.
-
Is there a way to implement the The
compose.ymlnetworks:
g3-net:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
services:
g3proxy:
container_name: g3proxy
image: g3proxy/comp:g3
build:
context: ./g3
dockerfile: g3proxy/docker/debian.Dockerfile
ports:
- "88:88"
- "80:80"
- "8080:8080"
- "443:443"
- "25:25"
- "587:587"
- "465:465"
- "143:143"
- "993:993"
- "4190:4190"
- "110:110"
- "995:995"
networks:
g3-net:
ipv4_address: 10.5.0.5
volumes:
- .:/g3/
command:
-c /g3/my_g3proxy.yml
who:
image: traefik/whoami:latest
hostname: who
container_name: who
networks:
g3-net:
ipv4_address: 10.5.0.9 my_g3proxy.ymllog: stdout
resolver:
- name: default
type: c-ares
escaper:
- name: default
type: direct_fixed
resolve_strategy: IPv4Only
resolver: default
- name: proxy_pp2
type: proxy_http
proxy_addr: "10.5.0.9:80"
use_proxy_protocol: 2
server:
- name: http2
escaper: proxy_pp2
type: http_proxy
listen:
address: "10.5.0.5:8080"
- name: port_pp2
type: plain_tcp_port
server: http0
proxy_protocol: 2
listen: "10.5.0.9:80"
- name: http0
escaper: default
type: http_proxy
|
Beta Was this translation helpful? Give feedback.
-
I'm going to try and run a Dockerized Stalwart-Mail server using
g3proxy
And have SPF, DKIM, TXT DNS records all validate for the Dockerized
Stalwart-Mail
server with the VPS's HOST's IP.I want use
g3proxy
to try to use theproxy-protocol
to send the HOST's IP to the Stalwart Email server.Internally, in the
Stalwart-Mail
server I will need set in a config file the IP of theg3proxy
proxy-protocol server.And, I will also need to supply
g3proxy
theIP
of theStalwart-Mail
server of where to send the proxy-protocol traffic.These are some of the
g3proxy
use cases I will likely need to cover,proxy protocol
,socks5
, andsni.
escaper_proxy_socks5
chain_proxy_protocol
simple_sni_proxy
I have momentarily below, only stubbed out the
Stalwart-Mail
server behind ag3proxy
http-rpoxy
compose.yml
my_g3proxy.yml
PORTS USED
Beta Was this translation helpful? Give feedback.
All reactions