I am trying to proxy SSH traffic from nginx (listening on port 7999) to a bitbucket server (listening on port 7998) on the back-end. Both nginx and bitbucket are running inside Docker containers. If I login to the nginx container and do telnet bitbucket.domain-name.com 7998
it connects. On the host machine if I do netstat -pnlt
I get:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::2377 :::* LISTEN 24477/dockerd
tcp6 0 0 :::7946 :::* LISTEN 24477/dockerd
tcp6 0 0 :::80 :::* LISTEN 24477/dockerd
tcp6 0 0 :::443 :::* LISTEN 24477/dockerd
tcp6 0 0 :::7999 :::* LISTEN 24477/dockerd
But, I when I do this on my computer: git clone ssh://[email protected]:7999/project_key/repo_name.git
I get
Cloning into 'repo_name'...
ssh: connect to host domain-name.com port 7999: Connection refused
fatal: Could not read from remote repository.
And when I do telnet domain-name.com 7999
I get telnet: Unable to connect to remote host: Connection refused
.
It seems the problem is nginx is not listening on port 7999 inside the docker container. But, on the host I can see dockerd
is listening on port 7999. I imagine I might not have the nginx config correct, but am not sure. Here are the relevant bits from the config files.
docker-compose.yaml (nginx)
services:
nginx:
ports:
- "80:8080"
- "443:8443"
- "7999:7997"
nginx.conf (inside the nginx container)
stream {
server {
listen 7997;
proxy_pass bitbucket1.cybertron.ninja:7998;
}
}
And here's some output executed inside the nginx container:
root@6d123f454eef:/# netstat -pnlt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 10/nginx: master pr
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 10/nginx: master pr
tcp 0 0 127.0.0.11:44703 0.0.0.0:* LISTEN -
Any ideas how to fix this issue? I'm stumped.