I have some trouble forwarding ports that are
LocalForward to the container via SSH Tunnel.
The whole network looks like this:
This is my
Dockerfile for the
FROM ubuntu:latest RUN apt-get update \ && apt-get install -y ssh \ && apt-get clean EXPOSE 80 COPY config /root/.ssh/config ENTRYPOINT ["ssh", "app-server", "sleep infinity & wait"]
Host vpn-gateway StrictHostKeyChecking no UserKnownHostsFile=/dev/null Hostname 10.20.30.40 User matrix Host app-server StrictHostKeyChecking no UserKnownHostsFile=/dev/null Hostname 22.214.171.124 User matrix ProxyCommand ssh vpn-gateway nc %h %p %r LocalForward 80 126.96.36.199:1080
Now, I am using
docker-compose for container orchestration with the following
version: "3.2" services: gateway: container_name: gateway image: gateway build: ./docker/gateway volumes: - ~/.ssh/id_rsa:/root/.ssh/id_rsa - ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub ports: - 8080:80
So, the idea is that if I run wget from localhost:
wget http://127.0.0.1:8080/api/health I will get a response from the
API Server machine (
188.8.131.52:1080). The problem is that I get reset:
--2018-06-25 07:19:26-- http://127.0.0.1:8080/api/health Connecting to 127.0.0.1:8080... connected. HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. Retrying. --2018-06-25 07:19:27-- (try: 2) http://127.0.0.1:8080/api/health Connecting to 127.0.0.1:8080... connected. HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. Retrying.
This could be caused by Docker not seeing any app using port 80 on the
GW Container as mentioned here: https://serverfault.com/a/769583/292211
exec to the
GW Container and run
wget http://127.0.0.1:80/api/health I am getting a proper response.
Is there a way to cheat docker into thinking port 80 is available in the
GW Container so it would allow me to forward port to the host? Or could any of these things be handled in a better way? All the mumbo-jumbo with SSH tunnels is due to third-party security restrictions.