Yes, this is a simply and stupid TCP proxy that listens in one address and talks to another one
Because when you develop, you don't want your project to talk to real API, IMAP, POP3, SMTP, SSH, ACME or [insert your acronym here] servers.
So, instead of configuring your app to talk to that server, you configure it to talk to the stupid proxy, and then the stupid proxy redirects connections to the correct server and port depending on the docker-compose environment you turn on.
Also you can use it to whitelist services in an internal network (see the related issue).
We use the official [Alpine][]-based [HAProxy][] image with a small configuration file.
Currently there are only these:
This variable defines the port where the underlying [HAProxy][] will listen,
and it must be written in the format used by the [bind
][] directive.
By default (:100
), it listens in every connection at port 100 (port 100?
that's stupid!... Yes, read the title ☝️😑).
The target TCP server and port that the proxy will be talking to, in the format
required by [HAProxy][]'s [server
][] directive.
By default (192.168.1.1:100
), it talks to a host IP in port 100 too.
Default: 5s
This variable sets the maximum inactivity time on the client side.
Default: 5s
This variable sets the inactivity timeout on the client side for half-closed connections.
Default: 5s
This variable sets the maximum time to wait for a connection attempt to a server to succeed.
Default: 5s
This variable sets the maximum inactivity time on the server side.
Default: 5s
This variable sets the inactivity timeout on the server side for half-closed connection.
Default: 5s
This variable sets the maximum inactivity time on the client and server side for tunnels.
version: "2.1"
services:
# Random app that needs an IMAP server at tcp://imap:143
app:
build: .
links:
- imap
# Production address to your real IMAP server
imap:
image: tecnativa/tcp-proxy
environment:
LISTEN: ":143"
TALK: "192.168.1.1:993"
version: "2.1"
services:
# Same configuration as in production for your app
app:
build: .
links:
- imap
# Connect to a fake IMAP server
imap:
image: tecnativa/tcp-proxy
environment:
LISTEN: ":143"
TALK: "192.168.1.1:143"