Skip to content

Meowzz95/docker-openvpn-socks5

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenVPN Docker Tunnel to SOCKS5 Server

Convers OpenVPN connection to SOCKS5 server in Docker. This allows you to have multiple OpenVPN to SOCKS5 proxies in different containers and expose to different host ports.

Supports latest Docker for both Windows, Linux, and MacOS.

Related Projects

What it does?

  1. It reads in an OpenVPN configuration file (.ovpn) from a mounted file, specified through OPENVPN_CONFIG environment variable.
  2. It starts the OpenVPN client program to establish the VPN connection.
  3. It starts the SOCKS5 server and listen on container-scoped port 1080 on default. SOCKS5 authentication can be enabled with SOCKS5_USER and SOCKS5_PASS environment variables. SOCKS5_PORT can be used to change the default port.
  4. It optionally executes the user specified CMD line from docker run positional arguments (see Docker doc). The program will use the VPN connection inside the container.
  5. If user has provided CMD line, and DAEMON_MODE environment variable is not set to true, then after running the CMD line, it will shutdown the OpenVPN client and terminate the container.

How to use?

Since it extends the openvpn-tunnel (GitHub) image, everything in openvpn-tunnel's document are still applicable on this image. Therefore, here we only provide an example that starts a daemon server that connects to VPN defined in file ./vpn.ovpn on host machine, and expose the SOCKS5 to host-scoped port at 7777.

# Unix
SET NAME="mysocks5"
PORT="7777"
USER="myuser"
PASS="mypass"
docker run --name "${NAME}" -dit --rm --device=/dev/net/tun --cap-add=NET_ADMIN \
    -v "${PWD}":/vpn:ro -e OPENVPN_CONFIG=/vpn/vpn.ovpn \
    -p "${PORT}":1080 \
    -e SOCKS5_USER="${USER}" \
    -e SOCKS5_PASS="${PASS}" \
    curve25519xsalsa20poly1305/openvpn-socks5

# Windows
SET NAME="mysocks5"
SET PORT="7777"
SET USER="myuser"
SET PASS="mypass"
docker run --name "%NAME%" -dit --rm --device=/dev/net/tun --cap-add=NET_ADMIN ^
    -v "%CD%":/vpn:ro -e OPENVPN_CONFIG=/vpn/vpn.ovpn ^
    -p "%PORT%":1080 ^
    -e SOCKS5_USER="%USER%" ^
    -e SOCKS5_PASS="%PASS%" ^
    curve25519xsalsa20poly1305/openvpn-socks5

Then on your host machine test it with curl:

# Unix & Windows
curl ifconfig.co/json -x socks5h://myuser:mypass@127.0.0.1:7777

To stop the daemon, run this:

# Unix
NAME="mysocks5"
docker stop "${NAME}"

# Windows
SET NAME="mysocks5"
docker stop "%NAME%"

Contributing

Please feel free to contribute to this project. But before you do so, just make sure you understand the following:

1. Make sure you have access to the official repository of this project where the maintainer is actively pushing changes. So that all effective changes can go into the official release pipeline.

2. Make sure your editor has EditorConfig plugin installed and enabled. It's used to unify code formatting style.

3. Use Conventional Commits 1.0.0-beta.2 to format Git commit messages.

4. Use Gitflow as Git workflow guideline.

5. Use Semantic Versioning 2.0.0 to tag release versions.

License

Copyright © 2019 curve25519xsalsa20poly1305 <curve25519xsalsa20poly1305@gmail.com>

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.

About

Converts OpenVPN connection to SOCKS5 proxy server in Docker

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 49.8%
  • Shell 28.9%
  • Dockerfile 21.3%