qoomon / docker-host

A docker sidecar container to forward all traffic to local docker host or any other host
MIT License
1.1k stars 88 forks source link

How to forward to other server/ip? #34

Closed damarges closed 4 years ago

damarges commented 4 years ago

Hi. Using your docker image for several apps running on my server on different ports to use them within docker environment.

But how can I forward not only to a port on host but to an arbitrary external ip?

My home pc is running some webserver application and is connected to my server via wireguard vpn! Once logged in remotely on my server I can reach the webserver of my home pc on the lan ip address assigned by wireguard. So connection is working and established between those two computers.

What I want to achieve is to reach my homeserver via my vps servers TLD i.e. home.mydomain.com (SSL encrypted with the help of nginx-proxy and the letsencrypt companion). What I am missing is some option to "expose" not only a port but an IP address.

How can I proceed now? Thanks for any help and push to the right direction.

damarges commented 4 years ago

I solved it by using local ssh-tunnel of the external ip to my servers host. And then using the qoomon docker-host image:

https://unix.stackexchange.com/questions/10428/simple-way-to-create-a-tunnel-from-one-local-port-to-another

with a line like ssh -g -L 8086:localhost:8085 -f -N username@10.0.0.11 where 10.0.0.11 is the ip of my homeserver within the wireguard lan

and using qomoon docker-compose like this: homehost: container_name: homeserver restart: always image: qoomon/docker-host cap_add: [ 'NET_ADMIN', 'NET_RAW' ] expose: - "8086" environment: VIRTUAL_HOST: home.mydomain.com LETSENCRYPT_HOST: home.mydomain.com LETSENCRYPT_EMAIL: mail@myisp.com