Call your unexposed container(s) without exposing it
- TCP Proxy (Layer 4)
- HTTP Proxy (Layer 7)
- Dynamically set target host via HTTP request header
- Install from source
go install github.com/anantadwi13/docker-proxy
- Run docker-proxy server locally
docker-proxy # or docker-proxy --mode http --target-host https://github.com/ # or docker-proxy --mode tcp --local-address :9999 --remote-address localhost:3306
- Download image from Docker Hub
docker pull anantadwi13/docker-proxy
- Run docker-proxy server via docker
docker run -it --name docker-proxy \ -p 80:80 \ anantadwi13/docker-proxy # or docker run -it --name docker-proxy \ -p 80:80 \ anantadwi13/docker-proxy --target-host https://github.com/ # or docker run -it --name docker-proxy \ -p 9999:9999 \ anantadwi13/docker-proxy --mode tcp --local-address :9999 --remote-address mysql-server:3306 # or docker run -it --name docker-proxy \ -p 80:80 \ --network network-name \ anantadwi13/docker-proxy
- Make sure docker-proxy server is already running
- Make an HTTP request or TCP connection
- (Optional for HTTP mode) Set
X-Target-Host
header with the target host (ex: https://google.com or http://another-container) - Send this HTTP request to
http://{docker_proxy_local_address}/...
or TCP connection todocker_proxy_local_address
Notes:
- Make sure docker-proxy is running as a container and connected to particular network if you want to proxy other containers
$ docker-proxy --help
Usage of docker-proxy:
-l, --local-address string local address (default ":80")
-m, --mode string proxy mode, http or tcp (default "http")
-r, --remote-address string remote address, required for tcp mode
-t, --target-host string target host, optional for http mode