{"id":13826077,"url":"https://github.com/root-gg/wsp","last_synced_at":"2025-08-22T07:14:54.987Z","repository":{"id":45409737,"uuid":"74557975","full_name":"root-gg/wsp","owner":"root-gg","description":"HTTP tunnel over Websocket","archived":false,"fork":false,"pushed_at":"2021-12-15T09:39:33.000Z","size":153,"stargazers_count":105,"open_issues_count":2,"forks_count":33,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-24T12:55:31.856Z","etag":null,"topics":["http","proxy","reverse-proxy","tunnel","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","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/root-gg.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}},"created_at":"2016-11-23T08:49:02.000Z","updated_at":"2025-03-09T14:46:23.000Z","dependencies_parsed_at":"2022-09-21T11:41:47.304Z","dependency_job_id":null,"html_url":"https://github.com/root-gg/wsp","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/root-gg%2Fwsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-gg%2Fwsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-gg%2Fwsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-gg%2Fwsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/root-gg","download_url":"https://codeload.github.com/root-gg/wsp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248232396,"owners_count":21069487,"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":["http","proxy","reverse-proxy","tunnel","websocket"],"created_at":"2024-08-04T09:01:31.767Z","updated_at":"2025-04-10T14:10:44.260Z","avatar_url":"https://github.com/root-gg.png","language":"Go","readme":"WS PROXY\n========\n\nThis is a reverse HTTP proxy over websockets.\nThe aim is to securely make call to internal APIs from outside.\n\nHow does it works\n-----------------\n\na WSP client runs in the internal network ( alongside the APIs )\nand connects to a remote WSP server with HTTP websockets.\n\nOne issue HTTP requests to the WSP server with an extra\nHTTP header 'X-PROXY-DESTINATION: \"http://api.internal/resource\"'\nto the /request endpoint.\n\nThe WSP Server then forward the request to the WSP Client over the\none of the offered websockets. The WSP Client receive and execute\nlocally an HTTP request to the URL provided in X-PROXY-DESTINATION\nand forwards the HTTP response back to the WSP server which in turn\nforwards the response back to the client. Please note that no\nbuffering of any sort occurs.\n\nIf several WSP clients connect to a WSP server, requests will be spread\nin a random way to all the WSP clients.\n\n![wsp schema](https://cloud.githubusercontent.com/assets/6413246/24397653/3f2e4b30-13a7-11e7-820b-cde6e784382f.png)\n\n\nGet code\n--------\n```\ngo get github.com/root-gg/wsp\n```\n\n\nWSP server configuration\n------------------------\n\n```\n# wsp_server.cfg\n---\nhost : 127.0.0.1                     # Address to bind the HTTP server\nport : 8080                          # Port to bind the HTTP server\ntimeout : 1000                       # Time to wait before acquiring a WS connection to forward the request (milliseconds)\nidletimeout : 60000                  # Time to wait before closing idle connection when there is enough idle connections (milliseconds)\n#blacklist :                         # Forbidden destination ( deny nothing if empty )\n# - method : \".*\"                    #   Applied in order before whitelist\n#   url : \"^http(s)?://google.*\"     #   None must match\n#   headers :                        #   Optinal header check\n#     X-CUSTOM-HEADER : \"^value$\"    # \n#whitelist :                         # Allowed destinations  ( allow all if empty )\n# - method : \"^GET$\"                 #   Applied in order after blacklist\n#   url : \"^http(s)?://.*$\"          #   One must match\n#   headers :                        #   Optinal header check\n#     X-CUSTOM-HEADER : \"^value$\"    # \n# secretkey : ThisIsASecret          # secret key that must be set in clients configuration\n```\n\n```\n$ cd wsp_server \u0026\u0026 go build\n$ ./wsp_server -config wsp_server.cfg\n{\n  \"Host\": \"127.0.0.1\",\n  \"Port\": 8080\n}\n2016/11/22 15:31:39 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:31:40 Registering new connection from 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n2016/11/22 15:33:34 GET map[User-Agent:[curl/7.26.0] Accept:[*/*] X-Proxy-Destination:[https://google.fr]]\n2016/11/22 15:33:34 proxy request to 7e2d8782-f893-4ff3-7e9d-299b4c0a518a\n```\n\nFor now TLS setup should be implemented using an HTTP reverse proxy\nlike NGinx or Apache...\n\nWSP proxy configuration\n-----------------------\n\n```\n# wsp_client.cfg\n---\ntargets :                            # Endpoints to connect to\n - ws://127.0.0.1:8080/register      #\npoolidlesize : 10                    # Default number of concurrent open (TCP) connections to keep idle per WSP server\npoolmaxsize : 100                    # Maximum number of concurrent open (TCP) connections per WSP server\n#blacklist :                         # Forbidden destination ( deny nothing if empty )\n# - method : \".*\"                    #   Applied in order before whitelist\n#   url : \".*forbidden.*\"            #   None must match\n#   headers :                        #   Optinal header check\n#     X-CUSTOM-HEADER : \"^value$\"    # \n#whitelist :                         # Allowed destinations  ( allow all if empty )\n# - method : \"^GET$\"                 #   Applied in order after blacklist\n#   url : \"http(s)?://.*$\"           #   One must match\n#   headers :                        #   Optinal header check\n#     X-CUSTOM-HEADER : \"^value$\"    # \n# secretkey : ThisIsASecret          # secret key that must match the value set in servers configuration\n```\n\n - poolMinSize is the default number of opened TCP/HTTP/WS connections\n to open per WSP server. If there is a burst of simpultaneous requests \n the number of open connection will rise and then decrease back to this\n number.\n - poolMinIdleSize is the number of connection to keep idle, meaning\n that if there is more than this number of simultaneous requests the\n WSP client will try to open more connections to keep idle connection.\n - poolMaxSize is the maximum number of simultaneous connection that\n the proxy will ever initiate per WSP server.\n\n```\n$ cd wsp_client \u0026\u0026 go build\n$ ./wsp_client -config wsp_client.cfg\n{\n  \"ID\": \"7e2d8782-f893-4ff3-7e9d-299b4c0a518a\",\n  \"Targets\": [\n    \"ws://127.0.0.1:8080/register\"\n  ],\n  \"PoolMinSize\": 10,\n  \"PoolMinIdleSize\": 5,\n  \"PoolMaxSize\": 100\n}\n2016/11/22 15:31:39 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:31:40 Connecting to ws://127.0.0.1:8080/register\n2016/11/22 15:33:34 got request : {\"Method\":\"GET\",\"URL\":\"https://google.fr\",\"Header\":{\"Accept\":[\"*/*\"],\"User-Agent\":[\"curl/7.26.0\"],\"X-Proxy-Destination\":[\"https://google.fr\"]},\"ContentLength\":0}\n```\n\nClient\n------\n\n```\n$ curl -H 'X-PROXY-DESTINATION: https://google.fr' http://127.0.0.1:8080/request\n\u003c!doctype html\u003e\u003chtml itemscope=\"\" itemtype=\"http://schema.org/WebPage\" lang=\"fr\"\u003e\u003chead\u003e\u003cmeta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"\u003e\u003cmeta content=\"/images/branding/googleg/1x/googleg_standard_color_128dp.png\" it...\n```\n","funding_links":[],"categories":["\u003ca id=\"01e6651181d405ecdcd92a452989e7e0\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"9d6789f22a280f5bb6491d1353b02384\"\u003e\u003c/a\u003e隧道\u0026\u0026穿透"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froot-gg%2Fwsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froot-gg%2Fwsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froot-gg%2Fwsp/lists"}