{"id":17339924,"url":"https://github.com/tg123/websockify-nginx-module","last_synced_at":"2025-04-14T16:32:57.394Z","repository":{"id":14127430,"uuid":"16832666","full_name":"tg123/websockify-nginx-module","owner":"tg123","description":"Embed websockify into Nginx  (convert any tcp connection into websocket) ","archived":false,"fork":false,"pushed_at":"2019-11-20T22:23:50.000Z","size":105,"stargazers_count":141,"open_issues_count":3,"forks_count":60,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-01T05:51:42.431Z","etag":null,"topics":["nginx","novnc","websocket","websocket-proxy","websockify"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tg123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"tg123"}},"created_at":"2014-02-14T09:23:35.000Z","updated_at":"2024-08-15T18:35:05.000Z","dependencies_parsed_at":"2022-09-23T19:12:35.962Z","dependency_job_id":null,"html_url":"https://github.com/tg123/websockify-nginx-module","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg123%2Fwebsockify-nginx-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg123%2Fwebsockify-nginx-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg123%2Fwebsockify-nginx-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tg123%2Fwebsockify-nginx-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tg123","download_url":"https://codeload.github.com/tg123/websockify-nginx-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223639403,"owners_count":17177816,"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":["nginx","novnc","websocket","websocket-proxy","websockify"],"created_at":"2024-10-15T15:43:32.310Z","updated_at":"2024-11-08T06:01:22.176Z","avatar_url":"https://github.com/tg123.png","language":"C","funding_links":["https://github.com/sponsors/tg123"],"categories":["C"],"sub_categories":[],"readme":"# Websockify port for Nginx\n\nEmbed the [Websockify](https://github.com/kanaka/websockify/) into Nginx\n\n## Installation\n\n\n    git clone https://github.com/tg123/websockify-nginx-module.git\n    \n    cd path/to/nginx_source\n    \n    ./configure --add-module=/path/to/websockify-nginx-module/\n    \n    make\n    make install\n\n\n## Uasge\n\n### Single noVNC websockify proxy\n\n  in your `nginx.conf`\n\n```\nlocation /websockify {\n    websockify_pass yourvncip:port\n}\n```\n    \n\n  1. visit \u003chttp://kanaka.github.io/noVNC/noVNC/vnc.html\u003e in your browser, \n  1. Host is your `nginx server`'s ip\n  1. port is your `nginx server`'s listening port\n  1. Click connect\n\n\n### Quick start with Docker\n\nProxy `192.168.188.42:5901` to your localhost/websockify.\n\n_Note_: 5901 is hardcoded in `nginx.vh.default.conf`\n\n```\ndocker run -d --add-host vnchost:192.168.188.42 -p 80:80 farmer1992/nginx-websockify\n```\n\n### Dynamic vnc upstream with help of [ngx-lua](https://github.com/chaoslawful/lua-nginx-module)\n\nan example script read ip and port from url params and verify them by md5 \n\n__SECURITY VULNERABILITY WARNING__ \n\n\u003e this is only an exmaple for you to understand how to work together with ngx-lua\n\u003e do NOT use this script in production.\n\n\u003e anyone who know your private key can connect any machine behind your nginx proxy,\n\u003e you should restrict target ip and port in a whitelist.\n\n\n  in your `nginx.conf`\n\n```\nlocation /websockify {\n\n    set $vnc_addr '';\n    access_by_lua '\n\n        -- your private key here\n        local key = \"CHANGE_ME_!!!!\"\n        \n        -- read from url params\n        local args = ngx.req.get_uri_args()\n        local ip = args[\"ip\"] or \"127.0.0.1\"\n        local port = args[\"port\"] or  \"5900\"\n        local sign = args[\"sign\"]\n        local t = tonumber(args[\"t\"]) or 0\n        local elapse = ngx.time() - t\n\n        -- make sure the signature are generated within 30 seconds\n        if elapse \u003e 30 or elapse \u003c 0  then\n            ngx.exit(ngx.HTTP_FORBIDDEN)\n        end\n\n        local addr = ip .. \":\" .. port\n\n        -- verify the signature\n        if ngx.md5(key .. t .. addr .. key) ~= sign then\n            ngx.exit(ngx.HTTP_FORBIDDEN)\n        end\n\n        ngx.var.vnc_addr = addr\n    ';\n\n    websockify_pass $vnc_addr;\n}\n```\n\nuse ajax call to `vnc_url.php` to retrieve the websockify url, then let noVNC connect to it.\n\n```\n\u003c?php\n\n// query you vnc ip and port from somewhere, e.g. mysql.\n//\n\n// query result\n$addr = '127.0.0.1';\n$port = 5900;\n\n// same as private key in nginx.conf\n$key = \"CHANGE_ME_!!!!\";\n\n$t = time();\n\necho '/websockify/?' . http_build_query(array(\n    't' =\u003e  $t,\n    'sign' =\u003e md5($key . $t . \"$addr:$port\" . $key),\n    'ip' =\u003e $addr,\n    'port' =\u003e $port,\n));\n```\n\n\n\n# Directives\n\n  * `websockify_buffer_size`:  Default: `65543 = 65535 + 4 + 4 (websocket max frame size + header + mask)`\n\n    The buffer size used to store the encode/decode data.\n    each websockify connection will cost `websockify_buffer_size` * 2 ( 1 upstream + 1 downstream ) addational memory\n\n\n  * `websockify_read_timeout`: Default `60s`\n    \n    [proxy_read_timeout](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout) of websockify upstream\n\n\n  * `websockify_connect_timeout`: Default `60s`\n    \n    [proxy_connect_timeout](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_connect_timeout) of websockify upstream\n\n\n  * `websockify_send_timeout`: Default `60s`\n    \n    [proxy_send_timeout](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_send_timeout) of websockify upstream\n\n    \n# Nginx Compatibility\n\n * v0.02 - v0.0.3\n    * 1.7.x (Tested on 1.7.9)\n    * 1.6.x (Tested on 1.6.2)\n\n * v0.0.1\n\n     * 1.5.x (Tested on 1.5.9)\n     * 1.4.x (Tested on 1.4.4)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftg123%2Fwebsockify-nginx-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftg123%2Fwebsockify-nginx-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftg123%2Fwebsockify-nginx-module/lists"}