{"id":22246211,"url":"https://github.com/jpbaking/proxied-openvpn","last_synced_at":"2026-01-06T07:03:33.975Z","repository":{"id":144051667,"uuid":"287635199","full_name":"jpbaking/proxied-openvpn","owner":"jpbaking","description":"proxied-openvpn","archived":false,"fork":false,"pushed_at":"2020-08-15T06:59:31.000Z","size":948,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T10:29:19.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpbaking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-14T22:26:37.000Z","updated_at":"2020-08-15T06:59:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca3717ab-9635-455f-bc68-2446080e93ec","html_url":"https://github.com/jpbaking/proxied-openvpn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fproxied-openvpn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fproxied-openvpn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fproxied-openvpn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fproxied-openvpn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpbaking","download_url":"https://codeload.github.com/jpbaking/proxied-openvpn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245450762,"owners_count":20617412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T05:26:39.386Z","updated_at":"2026-01-06T07:03:33.912Z","avatar_url":"https://github.com/jpbaking.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Proxied OpenVPN\n\nFor those that want a \"local\" proxy that routes traffic through OpenVPN, without having the WHOLE host machine be on OpenVPN. :P This will be a near-perfect solution for you...\n\n**TIP**: Use Proxy Auto-Configuration (PAC) files \u003c[guide](https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_(PAC)_file)\u003e\n\n**WARNING**: Not meant for production!!!\n\n## How to?\n\nPM2 (runner) inside the container will expect an EXECUTABLE (`chmod +x`) `/root/ovpn/connect.sh` script to be available inside the container (ie: mounted).\n\nExample, if \"`--volume $(pwd)/ovpn:/root/ovpn`\":\n\n* `./ovpn` directory contents:\n  ```bash\n  -rwxrwxr-x 1 someone someone  366 Aug 15 04:49 connect.sh\n  -rw-r--r-- 1 someone someone 2954 Aug 15 04:47 myvpn.ovpn\n  -rw-r--r-- 1 someone someone   50 Aug 14 21:18 myvpn.pass\n  ```\n  If `myvpn.ovpn` must is password-based: `auth-user-pass` must specify an absolute path.\n  \n  In this example, it'll be: `auth-user-pass /root/ovpn/myvpn.pass`\n* `./ovpn/connect.sh` contents:\n  ```bash\n  #!/bin/bash\n  # add some custom logic which dynamically modifies .ovpn\n  # or other pre-connect routines you want to add...\n  openvpn --config /root/ovpn/myvpn.ovpn 2\u003e\u00261\n  ```\n  ... or just very simply:\n  ```bash\n  #!/bin/bash\n  openvpn --config /root/ovpn/myvpn.ovpn 2\u003e\u00261\n  ```\n* Run:\n  ```bash\n  docker run --name proxied-openvpn \\\n    --detach --restart always \\\n    --cap-add=NET_ADMIN \\\n    --dns '8.8.8.8' \\\n    --publish 53128:3128 \\\n    --volume \"$(pwd)/ovpn:/root/ovpn\" \\\n    proxied-openvpn:latest\n  ```\n* Test:\n  ```bash\n  # Check docker host's public IP:\n  echo Host Public IP: \\\n    $(curl --silent https://api6.ipify.org)\n  # Check proxied-openvpn's public IP:\n  echo proxied-openvpn Public IP: \\\n    $(curl --silent --proxy http://127.0.0.1:53128 \\\n      https://api6.ipify.org)\n  ```\n  Sample output:\n  ```bash\n  $ echo Host Public IP: \\\n  \u003e   $(curl --silent https://api6.ipify.org)\n  Host Public IP: 252.32.109.191\n  \n  $ echo proxied-openvpn Public IP: \\\n  \u003e   $(curl --silent --proxy http://127.0.0.1:53128 \\\n  \u003e     https://api6.ipify.org)\n  proxied-openvpn Public IP: 189.187.163.238\n  ```\n\nVoila! You may now use it as `http_proxy`!\n\n## Static files web-hosting (w/ sample PAC)\n\nAs hinted above, you may want to opt for a Proxy Auto-Configuration (PAC).\n\nRef: [MDN web docs - Proxy Auto-Configuration (PAC) file](https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_(PAC)_file)\n\nOn top of hosting `.pac` files, you may host some other static files as well (as you need).\nJust mount the host directory where your static files are, to the container's `/var/www/html`. \n\nHere's an example:\n\n* `./static` directory contents:\n  ```bash\n  -rw-rw-r-- 1 core core 403 Aug 15 06:02 my.pac\n  ```\n* `./static/my.pac` contents (based on published port `53128` from buide above):\n  ```javascript\n  function FindProxyForURL(url, host) {\n    // DO NOT PROXY \"LOCAL\" IPs/HOSTNAMES:\n    if (isInNet(host, \"127.0.0.0\", \"255.0.0.0\") ||\n        isInNet(host, \"10.0.0.0\", \"255.0.0.0\") ||\n        isInNet(host, \"172.16.0.0\", \"255.240.0.0\") ||\n        isInNet(host, \"192.168.0.0\", \"255.255.0.0\") ||\n        isPlainHostName(host)) {\n      return \"DIRECT\";\n    }\n    // THEN PROXY EVERYTHING ELSE\n    return \"PROXY 127.0.0.1:53128\"\n  }\n  ```\n* Run:\n  ```bash\n  docker run --name proxied-openvpn \\\n    --detach --restart always \\\n    --cap-add=NET_ADMIN \\\n    --dns '8.8.8.8' \\\n    --publish 50080:80 \\\n    --publish 53128:3128 \\\n    --volume \"$(pwd)/ovpn:/root/ovpn\" \\\n    --volume \"$(pwd)/static:/var/www/html\" \\\n    proxied-openvpn:latest\n  ```\n  Note diff from example above in _\"How to?\"_: the `50080:80` port and `--volume \"$(pwd)/static:/var/www/html\"`.\n* Test #1:\n  ```bash\n  curl --verbose http://127.0.0.1:50080/my.pac\n  ```\n  Sample output:\n  ```bash\n  $ curl --verbose http://127.0.0.1:50080/my.pac\n  *   Trying 127.0.0.1:50080...\n  * TCP_NODELAY set\n  * Connected to 127.0.0.1 (127.0.0.1) port 50080 (#0)\n  \u003e GET /my.pac HTTP/1.1\n  \u003e Host: 127.0.0.1:50080\n  \u003e User-Agent: curl/7.68.0\n  \u003e Accept: */*\n  \u003e \n  * Mark bundle as not supporting multiuse\n  \u003c HTTP/1.1 200 OK\n  \u003c Date: Fri, 14 Aug 2020 22:07:28 GMT\n  \u003c Server: Apache/2.4.41 (Ubuntu)\n  \u003c Last-Modified: Fri, 14 Aug 2020 22:02:01 GMT\n  \u003c ETag: \"193-5acdd9212a2c7\"\n  \u003c Accept-Ranges: bytes\n  \u003c Content-Length: 403\n  \u003c Content-Type: application/x-ns-proxy-autoconfig\n  \u003c \n  function FindProxyForURL(url, host) {\n    // DO NOT PROXY \"LOCAL\" IPs/HOSTNAMES:\n    if (isInNet(host, \"127.0.0.0\", \"255.0.0.0\") ||\n        isInNet(host, \"10.0.0.0\", \"255.0.0.0\") ||\n        isInNet(host, \"172.16.0.0\", \"255.240.0.0\") ||\n        isInNet(host, \"192.168.0.0\", \"255.255.0.0\") ||\n        isPlainHostName(host)) {\n      return \"DIRECT\";\n    }\n    // THEN PROXY EVERYTHING ELSE\n    return \"PROXY 127.0.0.1:53128\"\n  * Connection #0 to host 127.0.0.1 left intact\n  ```\n* Test #2\n  \n  Set your Windows PAC:\n\n  ![windows-pac.png](./.screenshots/windows-pac.png)\n\n  Open in your browser: https://api6.ipify.org\n  \n  ![ipfy.png](./.screenshots/ipfy.png)\n\n## \u003ca name=\"license\" /\u003eLicense\n\n### MIT License\n\n#### Copyright (c) 2020 Joseph Baking\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n**THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpbaking%2Fproxied-openvpn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpbaking%2Fproxied-openvpn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpbaking%2Fproxied-openvpn/lists"}