DoganM95 / Ovpn-To-Proxy-Adapter

Creates http proxy servers out of .ovpn files from e.g. ExpressVPN, Surfshark, etc. , each running in a docker container. Automated for batch creation.
MIT License
13 stars 3 forks source link
docker ovpn proxy

Intro

Creates proxy servers for locations listed by a VPN provider, e.g. ExpressVPN, Surfshark, etc. Each (OpenVPN) location translates into a seperate docker container. The OpenVPN to Proxy conversion is provided by haugene/docker-transmission-openvpn.

Features

Setup

Usage

Notes

Script parameters

Single proxy creation

sudo ./spawn.sh \
    <vpn_location> \
    <vpn_provider> \
    <starting_port> \
    <vpn_username> \
    <vpn_password> \
    <container_restart> \
    <network_cidr>

Example:

Create a proxy server, which connects to "Hong Kong - 2" and be available on port 8900:

sudo ./spawn.sh \
    my_expressvpn_hong_kong_-_2_udp.ovpn \
    EXPRESSVPN \
    8900 \
    y7v1wwy6wg5vh8s9jfn2sj3c \
    ixay8f10fdljm31zks09x287 \
    always \
    192.168.0.0/24

Multi proxy creation (batch)

sudo ./spawn.sh \
    list \
    <vpn_provider> \
    <starting_port> \
    <vpn_username> \
    <vpn_password> \
    <container_restart> \
    <network_cidr>

Example:

If ovpn_list file contains

jp-tok-st014.prod.surfshark.com_udp.ovpn
ua-iev.prod.surfshark.com_udp.ovpn
us-nyc.prod.surfshark.com

Then the following would create 3 proxy servers, one for each location. First (Japan) would listen on port 8900, Second (Ukraine) on port 8901, etc.

sudo ./spawn.sh \
    list \
    SURFSHARK \
    8900 \
    someone@something.com \
    8x5o60nz22gll9o8qsf63to2 \
    on-failure:5 \
    192.168.0.0/24

Useful docker commands

Stop all openvpn containers

docker ps -a --format "{{.Names}}" | grep "openvpn" | xargs -r -I {} docker stop {}

Stop and remove all openvpn containers

docker ps -a --format "{{.Names}}" | grep "openvpn" | xargs -r -I {} docker rm -f {}

Remove only stopped openvpn containers

docker ps -a --filter "status=exited" --format "{{.ID}} {{.Names}}" | grep openvpn | cut -d ' ' -f1 | xargs docker rm -f

Shell into the container (if only one is running)

docker exec -it $(docker ps -a --format '{{.Names}}' | grep 'openvpn' | head -n 1) /bin/sh

Show logs of the container (in only one is running)

docker logs $(docker ps -a --format '{{.Names}}' | grep 'openvpn' | head -n 1)