{"id":22246226,"url":"https://github.com/jpbaking/cpto","last_synced_at":"2025-03-25T11:23:56.547Z","repository":{"id":144051658,"uuid":"364954281","full_name":"jpbaking/cpto","owner":"jpbaking","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-10T01:31:42.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T10:29:24.293Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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":"2021-05-06T15:21:03.000Z","updated_at":"2021-05-10T01:31:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0c2e67a-8a12-4646-b037-8d220a769ca6","html_url":"https://github.com/jpbaking/cpto","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%2Fcpto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fcpto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fcpto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpbaking%2Fcpto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpbaking","download_url":"https://codeload.github.com/jpbaking/cpto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245450778,"owners_count":20617416,"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:40.604Z","updated_at":"2025-03-25T11:23:56.521Z","avatar_url":"https://github.com/jpbaking.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPTO\n\nContainerized HTTP/SOCKS Proxy Through OpenVPN\n\n![PREVIEW](./.images/preview.png)\n\nThis will expose HTTP/SOCKS proxy ports that forwards traffic through the OpenVPN client configured. Perfect for those that don't want/need to have their entire host machine be on the OpenVPN network.\n\n\u003e **WARNING**: This project was made for educational purposes (and convenience). Please DO NOT USE for PRODUCTION or COMMERCIAL deployments.\n\n... also serves as demonstration of:\n- Non-typical `docker`/`docker-compose` (POD-like) networking _([official doc](https://docs.docker.com/compose/compose-file/compose-file-v2/#network_mode))_\n- YAML anchors in `docker-compose.yaml` _([guide by medium.com](https://medium.com/@kinghuang/docker-compose-anchors-aliases-extensions-a1e4105d70bd))_\n- Working with Alpine images _([official site](https://alpinelinux.org/about/) / [in docker hub](https://hub.docker.com/_/alpine))_\n- `docker` Multi-stage builds _([official doc](https://docs.docker.com/develop/develop-images/multistage-build/))_\n- Git submodules _([official doc](https://git-scm.com/book/en/v2/Git-Tools-Submodules))_\n- Oldie-but-Goodie (and tiny) open-source networking apps/tools:\n  - tinyproxy _([official site](http://tinyproxy.github.io/) / [github](https://github.com/tinyproxy/tinyproxy))_\n  - srelay _([official site](https://socks-relay.sourceforge.io/) / [sourceforge](https://sourceforge.net/p/socks-relay/srelay/ci/master/tree/))_\n  - haproxy _([official site](http://www.haproxy.org/) / [github](https://github.com/haproxy/haproxy))_\n\n**REF:** https://github.com/jpbaking/cpto\n\n# Usage\n\n## **Step #1:** Clone this repository\n\n```bash\n$ git clone git@github.com:jpbaking/cpto.git\n$ cd cpto\n```\n\nThis `.git` repository is basically a `docker-compose` project:\n\n```bash\n$ ls -la\ntotal 56\ndrwxrwxr-x  8 user group 4096 May  6 16:01 .\ndrwxrwxr-x 10 user group 4096 May  6 15:31 ..\n-rwxrwxr-x  1 user group  307 May  6 15:31 compose.sh\ndrwxrwxr-x  2 user group 4096 May  6 15:33 cpto-haproxy\ndrwxrwxr-x  2 user group 4096 May  6 15:33 cpto-openvpn\ndrwxrwxr-x  2 user group 4096 May  6 15:33 cpto-srelay\ndrwxrwxr-x  2 user group 4096 May  6 15:33 cpto-tinyproxy\n-rw-rw-r--  1 user group 1110 May  6 15:50 docker-compose.yaml\n-rw-rw-r--  1 user group 1491 May  6 16:06 .env\ndrwxrwxr-x  9 user group 4096 May  6 15:32 .git\n-rw-rw-r--  1 user group   15 May  6 15:31 .gitignore\n-rw-rw-r--  1 user group  387 May  6 15:31 .gitmodules\ndrwxr-xr-x  2 user group 4096 May  6 15:53 .openvpn\n-rw-rw-r--  1 user group 2601 May  6 16:14 README.md\n```\n\nFeel free to use the `compose.sh` bash script. It basically is a `docker-compose` helper/shortcut that checks if `docker` and `docker-compose` are installed, and consistently supplies the `--project-name=cpto` argument.\n\n### **OPTIONAL:** \"pull\" the submodules:\n\nIf you're curious or want to hack something:\n```bash\n$ git submodule update --init --recursive\n```\nEnjoy!~\n\n## **Step #2:** Configuration (REQUIRED)\n\nModify the [docker compose `.env`](https://docs.docker.com/compose/environment-variables/#the-env-file) file:\n\n```bash\n# -------------------------------------------------------------------------\n# [OPENVPN_CONFIG_DIR]\n# The folder that holds your OpenVPN client configuration (and possibly a\n# password file as well). If you do not need to pass configuration files\n# (eg: if you only need OpenVPN arguments), you may leave the detault value\n# as-is (it won't have any effect anyway).\n# -------------------------------------------------------------------------\nOPENVPN_CONFIG_DIR=\"./.openvpn\"\n\n# -------------------------------------------------------------------------\n# [OPENVPN_CMD_ARGS]\n# This exactly is what will be fed as arguments/parameters to OpenVPN.\n# Something like: `openvpn ${OPENVPN_CMD_ARGS}`\n# NOTE: The working directory in the container will be the mounted volume\n#       pointing to the directory specified in `OPENVPN_CONFIG_DIR`.\n# -------------------------------------------------------------------------\nOPENVPN_CMD_ARGS=\"--config client.ovpn --auth-user-pass client.pass --auth-nocache\"\n\n# -------------------------------------------------------------------------\n# [HTTP_PROXY_PORT]\n# The port to expose for HTTP Proxy (tinyproxy).\n# -------------------------------------------------------------------------\nHTTP_PROXY_PORT=\"3128\"\n\n# -------------------------------------------------------------------------\n# [SOCKS_PROXY_PORT]\n# The port to expose for SOCKS4/SOCKS5 Proxy (srelay).\n# -------------------------------------------------------------------------\nSOCKS_PROXY_PORT=\"1080\"\n```\n\n## **Step #3:** Docker Compose CLI\n\n`compose.sh` ([docker-compose](https://docs.docker.com/compose/reference/)) usage:\n\n* \"Start\": `./compose.sh pull \u0026\u0026 ./compose.sh up --detach --no-build`\n* \"Stop\": `./compose.sh down`\n* List Containers: `./compose.sh ps`\n* Tail-Follow Logs: `./compose.sh logs -f --tail 100`\n* I hacked something, now...\n  * Build: `./compose.sh build`\n  * Build \u0026 \"Start\": `./compose.sh up --detach --build`\n\n**REF:** [https://docs.docker.com/compose/reference/](https://docs.docker.com/compose/reference/)\n\n\n## **Step #4:** Test (optional)\n\nJust execute `test.sh`! It will also show you sample usage with `curl`:\n\n```bash\n$ ./test.sh\n\nCMD: curl -s https://checkip.amazonaws.com\nYour home WAN IP: 111.111.111.111\n\nCMD: curl -s --proxy http://127.0.0.1:3128 https://checkip.amazonaws.com\nIP through HTTP Proxy (port: 3128): 222.222.222.222\n\nCMD: curl -s --proxy socks4://127.0.0.1:1080 https://checkip.amazonaws.com\nIP through SOCKS4 Proxy (port: 1080): 222.222.222.222\n\nCMD: curl -s --proxy socks5://127.0.0.1:1080 https://checkip.amazonaws.com\nIP through SOCKS5 Proxy (port: 1080): 222.222.222.222\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpbaking%2Fcpto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpbaking%2Fcpto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpbaking%2Fcpto/lists"}