SOCKS5 and Service Tunnels via Stunnel

Pomelo uses stunnel in client mode to reach services on the current application server (gravlax) over mutually-authenticated TLS. Three tunnels are active. Authentication uses the private PKI — see ssl/pki for cert details and file locations.

Active tunnels

NamePomelo portRemotePurpose
socks5hlocalhost:1080gravlax:11080SOCKS5 proxy (microsocks on gravlax)
noteslocalhost:8021gravlax:18021Notes API (gdata-server on gravlax)
notes-mcplocalhost:8023gravlax:18023Notes MCP (gdata-mcp-server on gravlax)
imaplocalhost:143cv.critchley.biz:993IMAP (public cert, separate CA)

Config: /etc/stunnel/stunnel.conf on pomelo. checkHost = John Critchley verifies the server CN on all three gravlax tunnels.

Switching to a different application server

Edit /etc/stunnel/stunnel.conf and change connect = gravlax:... to the new host in all three gravlax sections, then systemctl restart stunnel4. The new server must have been provisioned with setup_server.yml --tags stunnel.

s5pin.py — Local Port Forwarder

Located at ~/py/s5pin.py. Aliased as s5pin. Listens on a local port and proxies each connection through the SOCKS5 server to a fixed remote host:port. Async, handles multiple simultaneous connections. Supports IPv4, IPv6, and domain name targets.

# Expose a remote service on gravlax's network as localhost:5432
s5pin --listen-port 5432 \
      --remote-host db.internal \
      --remote-port 5432 \
      --socks-host localhost \
      --socks-port 1080

Defaults: listen on 127.0.0.1:8008, SOCKS at localhost:1080, remote localhost:80.

Relevance to Envoy API Calls

s5pin can expose non-public REST services on gravlax's network as local ports, making them reachable by the envoy API call mechanism. See API Registration.

version 2  ·  created 2026-03-22  ·  updated 2026-06-05  ·  tags ['stunnel', 'socks5', 'tls', 'proxy', 'networking']