Skip to content

Docker compose OpenVPN client with HTTP and SSH proxy

License

Notifications You must be signed in to change notification settings

mrauhu/docker-openvpn-http-ssh-proxy

Repository files navigation

Docker compose OpenVPN client with HTTP and SSH proxy

Provides a Proxy Auto-Configuration script URL for easy setup.

Prerequisites

Installation

Clone repository:

git clone https://github.com/mrauhu/docker-openvpn-http-ssh-proxy
cd docker-openvpn-http-ssh-proxy

Setup

OpenVPN client

  1. Copy your OpenVPN client config with certificates to the config/ directory.

  2. Create the .env file and set values:

    OPENVPN_USERNAME=
    OPENVPN_PASSWORD=
    # Comma separated list, like: `a.example.com,b.example.com,*.internal.example.com`
    OPENVPN_TUNNEL_HOSTS=
    # Name of config file, like: `config.ovpn`
    OPENVPN_CONFIG_FILE=

    Optionally, you can override default values in the .env file:

    OPENVPN_HOST=127.0.0.1
    OPENVPN_PROXY_AUTO_CONFIGURATION_PORT=8081
    OPENVPN_PROXY_HTTP_PORT=8080
    OPENVPN_PROXY_SSH_PORT=2222

HTTP proxy

Use the Proxy Auth-Configuration (PAC) script URL:

http://127.0.0.1:8081

The URL based on pattern built from environment variables:

http://${OPENVPN_HOST}:${OPENVPN_PROXY_AUTO_CONFIGURATION_PORT}

For:

  • macOS

    In System Preferences — Network — Proxies — Automatic Proxy Configuration protocol:

    • set Proxy Configuration File URL.
  • Windows

    In Settings — Network & Internet — Proxy:

    • check:
      • Automatically detect settings;
      • Use script setup;
    • set Script address.

SSH proxy

As example, for Git:

  1. Edit the .ssh/config file, for:

    • macOS

      nano ~/.ssh/config
    • Windows

      notepad %USERPROFILE%\.ssh\config
  2. Add lines:

    Host REMOTE_HOST_NAME
      Hostname REMOTE_HOST_NAME
      User git
      IdentityFile ~/.ssh/PRIVATE_KEY_FILE
      ProxyCommand ssh -W %h:%p ssh-proxy
    
    Host ssh-proxy
      Hostname 127.0.0.1
      Port 2222
      User root
      IdentityFile ~/.ssh/PRIVATE_KEY_FILE
    

    And substitute variables:

    • REMOTE_HOST_NAME — name of a remote host, example: git.example.com;
    • PRIVATE_KEY_FILE — your private key file, example: id_ed25519.
  3. Add content of a public key file to the root/.ssh/authorized_keys file, for:

    • macOS:

      cat ~/.ssh/PUBLIC_KEY_FILE >> root/.ssh/authorized_keys
    • Windows:

      type %USERPROFILE%\.ssh\PUBLIC_KEY_FILE >> root\.ssh\authorized_keys

    Where:

    • PUBLIC_KEY_FILE — your public key file, example id_ed25519.pub.

Usage

Start in background

docker-compose up -d

Stop and remove containers

docker-compose down

Update and rebuild images

git pull --ff-only && docker-compose build

Contributing

Read the How to contribute guide.

License

Apache 2.0

© Sergey N