### Example: Proxy Transmission Service via Nginx Source: https://github.com/dperson/openvpn-client/blob/master/README.md This example shows a concrete implementation of the Nginx proxy. It first runs the dperson/transmission container with its traffic routed through the VPN, then starts a dperson/nginx container to proxy requests for the Transmission web UI to the correct host and port within the VPN network. ```bash sudo docker run -it --name bit --net=container:vpn -d dperson/transmission sudo docker run -it --name web -p 80:80 -p 443:443 --link vpn:bit \ -d dperson/nginx -w "http://bit:9091/transmission;/transmission" ``` -------------------------------- ### Run a Command Instead of OpenVPN Source: https://github.com/dperson/openvpn-client/blob/master/README.md If a valid command is provided, it will be executed instead of starting the OpenVPN client. ```shell openvpn.sh [command] ``` -------------------------------- ### Run OpenVPN Client Instance with Docker Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command starts an OpenVPN client container, establishing a VPN connection. It requires copying the VPN certificate, mounting a volume for VPN configuration, and passing server details (name, username, password). The container is run in detached mode and is named 'vpn'. ```bash sudo cp /path/to/vpn.crt /some/path/vpn-ca.crt sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -d dperson/openvpn-client \ -v 'vpn.server.name;username;password' sudo docker restart vpn ``` -------------------------------- ### OpenVPN Client Configuration File Source: https://github.com/dperson/openvpn-client/blob/master/README.md This is an example OpenVPN client configuration file (`vpn.conf`) that specifies connection parameters, including the CA certificate, client certificate, and client key. ```openvpn client dev tun port 1194 proto udp remote vpn.server.name 1194 nobind ca /vpn/vpn-ca.crt cert /vpn/client.crt key /vpn/client.key persist-key persist-tun ``` -------------------------------- ### Setup Firewall Rules Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option configures firewall rules to ensure that only VPN and DNS traffic can access the internet. An optional port can be specified. ```shell openvpn.sh -f '[port]' ``` -------------------------------- ### Proxy Multiple Services via Nginx through VPN Source: https://github.com/dperson/openvpn-client/blob/master/README.md This example extends the Nginx proxy functionality to handle multiple services. It starts separate containers for 'transmission' and a hypothetical 'foo' service, both routed through the VPN. The Nginx container is then configured with multiple `-w` arguments to proxy requests to each service independently. ```bash sudo docker run -it --name bit --net=container:vpn -d dperson/transmission sudo docker run -it --name foo --net=container:vpn -d dperson/foo sudo docker run -it --name web -p 80:80 -p 443:443 --link vpn:bit \ --link vpn:foo -d dperson/nginx \ -w "http://bit:9091/transmission;/transmission" \ -w "http://foo:8000/foo;/foo" ``` -------------------------------- ### Run OpenVPN Client with Local Network Routing Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command starts the OpenVPN client container and configures it to route traffic for a specific local network (e.g., 192.168.1.0/24) through the VPN. It requires the VPN certificate, a volume mount for configuration, the local network CIDR, and VPN server credentials. The `-r` flag specifies the local network to route. ```bash sudo cp /path/to/vpn.crt /some/path/vpn-ca.crt sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -d dperson/openvpn-client \ -r 192.168.1.0/24 -v 'vpn.server.name;username;password' ``` -------------------------------- ### Connect Other Containers to VPN Network Source: https://github.com/dperson/openvpn-client/blob/master/README.md After starting the OpenVPN client, other containers can utilize its network stack by using the `--net=container:vpn` option. This command launches a generic Docker container named 'some/docker-container' and routes its traffic through the established VPN connection. ```bash sudo docker run -it --net=container:vpn -d some/docker-container ``` -------------------------------- ### Set Timezone Environment Variable Source: https://github.com/dperson/openvpn-client/blob/master/README.md The TZ environment variable can be used to set the timezone within the container. For example, 'EST5EDT'. ```shell export TZ=EST5EDT ``` -------------------------------- ### Display Help for openvpn-client Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command displays the help message for the openvpn-client script, showing all available options and their usage. It's the primary way to understand the script's functionality. ```shell sudo docker run -it --rm dperson/openvpn-client -h ``` -------------------------------- ### Run OpenVPN Client with Client Certificates (Docker) Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command runs the OpenVPN client in a Docker container, mounting a directory containing the VPN configuration file and client certificate/key files. It's used for establishing VPN connections with client certificate authentication. ```docker sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -d dperson/openvpn-client ``` -------------------------------- ### Configure OpenVPN Connection with Server, User, and Password Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option configures a new OpenVPN connection by providing the server address, username, and password. It can also optionally include a port and protocol. ```shell sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -e TZ=EST5EDT -d dperson/openvpn \ -v 'vpn.server.name;username;password' ``` -------------------------------- ### Run OpenVPN Client with Configuration and Command-Line Auth (Docker) Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command executes the OpenVPN client within a Docker container, using a client configuration file named `vpn.conf` located in a mounted volume and providing the VPN username and password via command-line arguments. ```docker sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -d dperson/openvpn-client -a 'username;password' ``` -------------------------------- ### Run OpenVPN Client with VPN Configuration and Auth (Docker) Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command runs the OpenVPN client in a Docker container, mounting a volume for VPN configuration files and providing server details, username, and password. ```docker sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -d dperson/openvpn-client \ -v 'vpn.server.name;username;password' ``` -------------------------------- ### Specify VPN Configuration Files Source: https://github.com/dperson/openvpn-client/blob/master/README.md The VPN_FILES environment variable allows specifying the VPN configuration and certificate files to use, relative to the /vpn directory. Files are separated by a semicolon. ```shell export VPN_FILES='[;cert]' ``` -------------------------------- ### Run OpenVPN Client with DNS Configuration (Docker) Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command configures the OpenVPN client container to use a specific DNS server (e.g., Google DNS at 8.8.4.4) to resolve network issues. It involves mounting a volume for VPN configuration and providing authentication. ```docker sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ --dns 8.8.4.4 -v /some/path:/vpn -d dperson/openvpn-client \ -v 'vpn.server.name;username;password' ``` -------------------------------- ### Proxy Local Services via Nginx through VPN Source: https://github.com/dperson/openvpn-client/blob/master/README.md This demonstrates how to run a Nginx web server that proxies requests to services running within the VPN. It maps host ports 80 and 443 to the Nginx container and links it to the VPN container. The `-w` argument specifies the mapping from a URL path to a service and port within the VPN. ```bash sudo docker run -it --name web -p 80:80 -p 443:443 \ --link vpn: -d dperson/nginx \ -w "http://:/;/" ``` -------------------------------- ### Run OpenVPN Client with Firewall Enabled (Docker) Source: https://github.com/dperson/openvpn-client/blob/master/README.md This command launches the OpenVPN client container with a firewall enabled, which blocks outbound traffic if the VPN connection drops. It requires mounting a volume for VPN configuration and providing authentication details. ```docker sudo docker run -it --cap-add=NET_ADMIN --device /dev/net/tun --name vpn \ -v /some/path:/vpn -d dperson/openvpn-client -f "" \ -v 'vpn.server.name;username;password' ``` -------------------------------- ### Configure VPN Username and Password Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option allows setting the username and password for VPN authentication, separated by a semicolon. ```shell openvpn.sh -a '' ``` -------------------------------- ### Pass Custom Arguments to OpenVPN Source: https://github.com/dperson/openvpn-client/blob/master/README.md This allows passing arbitrary arguments directly to the underlying OpenVPN client. Arguments should be provided as a space-separated string. ```shell openvpn.sh -o '' ``` -------------------------------- ### Add IPv6 Route Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option adds a CIDR IPv6 network route, allowing replies to your private network once the VPN is established. ```shell openvpn.sh -R '' ``` -------------------------------- ### Configure Authentication Password for Certificate Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option sets a password required to access the VPN certificate. The password must be enclosed in single quotes. ```shell openvpn.sh -c '' ``` -------------------------------- ### Add IPv4 Route Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option adds a CIDR IPv4 network route, enabling replies to your private network when the VPN is active. ```shell openvpn.sh -r '' ``` -------------------------------- ### Forward a Port Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option configures port forwarding for the VPN connection. It requires a port number and optionally accepts a protocol (tcp or udp). ```shell openvpn.sh -p '[;protocol]' ``` -------------------------------- ### Set Maximum Segment Size (MSS) Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option sets the Maximum Segment Size (MSS) for the VPN connection. The required argument is the desired MSS value. ```shell openvpn.sh -m '' ``` -------------------------------- ### Use VPN Provider's DNS Resolvers Source: https://github.com/dperson/openvpn-client/blob/master/README.md This option configures the container to use the DNS resolvers provided by the VPN service. Note that this is incompatible with read-only containers. ```shell openvpn.sh -d ``` -------------------------------- ### Set Group ID Environment Variable Source: https://github.com/dperson/openvpn-client/blob/master/README.md The GROUPID environment variable can be used to set the GID (Group ID) for the VPN process within the container. ```shell export GROUPID= ``` -------------------------------- ### Disable Default Route Source: https://github.com/dperson/openvpn-client/blob/master/README.md When this option is used, the VPN connection will not be set as the default route for network traffic. ```shell openvpn.sh -D ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.