A docker container for using an openconnect VPN via an proxy
- Create a config file
~/.openconnect/config
andchmod 600 ~/.openconnect/config
# Example Configuration
server=vpn.example.com/examplegroup
user=<YOUR USERNAME>
# As openconnect does not support passing a password via config the password needs to be in a comment ("#password"):
#password=<YOUR PASSCODE>
token-mode=totp
token-secret=base32:<YOUR TOTP SECRET>
-
Then fire up the container by
docker compose up
and enjoy your proxy server underlocalhost:58443
-
Use the proxy
http_proxy=http://localhost:58443 curl http://example.com
# OR
ssh -o ProxyCommand="nc -x localhost:58443 %h %p" [email protected]
# OR
google-chrome-beta --proxy-server="socks5://127.0.0.1:58443"
Be AWARE of the security risk of storing clear passwords. An alternative is passing credentials via the environment through docker, read from a passwordmanager like pass
in an external wrapper script.
The password and secret can be passed via the Environment Variables OPENCONNECTPROXY_PASSCODE
and OPENCONNECTPROXY_TOKEN_SECRET
to docker compose up
Passing cert files can easily be done by adding to the volumes
definition in docker-compose.yml
This wrapper script starts a google-chrome-beta
together with the docker container and on close terminates both. I personally use google-chrome-beta
to avoid clashing with my running google-chrome-stable
...
This is clearly more to be seen as an Example than a way to use it for everyone.
Inspiration for this came from https://github.com/makinacorpus/docker-fortivpn