azinchen/nordvpn

How to access VPN container from Internet?

exactsameproblem opened this issue · 0 comments

Hello there,
I set up a docker compose file (see code below) which would let me tunnel docker containers through nordvpn.

The problem is that I cannot access my container(s) outside of LAN (and I'm using Cloudflare on my domain).

version: '3.2'
services:
    haproxy:
        container_name: haproxy
        image: haproxy
        ports:
           - "80:8080" # http-in
           - "443:443" # https-in with ssl cert (cloudflare)
        volumes:
           - ./haproxy:/usr/local/etc/haproxy

vpn:
        depends_on:
            - haproxy
        container_name: nordvpn
        image: azinchen/nordvpn:latest
        cap_add:
            - net_admin
        devices:
            - /dev/net/tun
        environment:
           - USER=mail
           - PASS=pass
           - COUNTRY=Germany;IE;131
           - GROUP=Standard VPN servers
           - RANDOM_TOP=10
           - RECREATE_VPN_CRON=5 */3 * * *
           - NETWORK=172.26.0.0/16;177.17.0.0/16;177.20.0.0/16 # tried differents ip with no sucess
           - OPENVPN_OPTS=--mute-replay-warnings
     
        restart: unless-stopped

 pwd:
        depends_on:
            - vpn
        network_mode: service:vpn 
        # pwd daemon container always needs to be named this way
        container_name: pwd
        # use the latest golang image
        image: golang
        # go to the right place and starts the app
        command: /bin/sh -c 'ssh-keygen -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key >/dev/null; cd /go/src/; if [ -e /runbin/pwd ]; then /runbin/pwd  -save /pwd/sessions -name l2; else go run api.go -save /pwd/sessions -name l2; fi'
        volumes:
            # since this app creates networks and launches containers, we need to talk to docker daemon
            - /var/run/docker.sock:/var/run/docker.sock
            # mount the box mounted shared folder to the container
            - $PWD:/go/src
            - sessions:/pwd

    l2:
        depends_on:
            - vpn2
        network_mode: service:vpn2	
        container_name: l2
        # use the latest golang image
        image: golang
        # go to the right place and starts the app
        command: /bin/sh -c 'ssh-keygen -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key >/dev/null; cd /go/src/router/l2; if [ -e /runbin/l2 ]; then /runbin/l2 -ssh_key_path /etc/ssh/ssh_host_rsa_key -name l2 -save /pwd/networks; else go run l2.go -ssh_key_path /etc/ssh/ssh_host_rsa_key -name l2 -save /pwd/networks; fi'
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - $PWD:/go/src
            - networks:/pwd
        ports:
            - "8022:22"
            - "8053:53"   

volumes:
    sessions:
    networks:

PWD allows me to create linux containers on the fly, and I would like to be able to pass them through nordvpn...
PWD expose port 3000.
haproxy has a backend : 80 or 443 (ssl cert) to 3000.

Any help would be greatly appreciated!