1websockify(1)                    USER COMMANDS                   websockify(1)
2
3
4

NAME

6       websockify - WebSockets to TCP socket bridge
7
8

SYNOPSIS

10        websockify [options] [source_addr:]source_port target_addr:target_port
11        websockify [options] [source_addr:]source_port -- WRAP_COMMAND_LINE
12
13

OPTIONS

15        -h, --help         show this help message and exit
16        -v, --verbose      verbose messages and per frame traffic
17        --record=FILE      record sessions to FILE.[session_number]
18        -D, --daemon       become a daemon (background process)
19        --run-once         handle a single WebSocket connection and exit
20        --timeout=TIMEOUT  after TIMEOUT seconds exit when not connected
21        --cert=CERT        SSL certificate file
22        --key=KEY          SSL key file (if separate from cert)
23        --ssl-only         disallow non-encrypted connections
24        --web=DIR          run webserver on same port. Serve files from DIR.
25        --wrap-mode=MODE   action to take when the wrapped program exits or
26                            daemonizes: exit (default), ignore, respawn
27
28

DESCRIPTION

30       At  the most basic level, websockify just translates WebSockets traffic
31       to normal TCP socket traffic. Websockify accepts the  WebSockets  hand‐
32       shake, parses it, and then begins forwarding traffic between the client
33       and the target in both directions.
34
35       websockify was formerly  named  wsproxy  and  was  part  of  the  noVNC
36       project.
37
38

NOTES

40   WebSockets binary data
41       Websockify  supports all versions of the WebSockets protocol (Hixie and
42       HyBI). The older Hixie versions of the protocol only support UTF-8 text
43       payloads. In order to transport binary data over UTF-8 an encoding must
44       used to encapsulate the data within UTF-8. Websockify  uses  base64  to
45       encode  all  traffic  to  and from the client. This does not affect the
46       data between websockify and the server.
47
48
49   Encrypted WebSocket connections (wss://)
50       To encrypt the traffic using the WebSocket 'wss://' URI scheme you need
51       to generate a certificate for websockify to load. By default websockify
52       loads a certificate file name self.pem but the --cert=CERT  option  can
53       override  the  file  name.  You  can generate a self-signed certificate
54       using openssl. When asked for the common name, use the hostname of  the
55       server where the proxy will be running:
56
57       openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
58
59
60   Websock Javascript library
61       The  websock.js  (see  https://github.com/kanaka/websockify) Javascript
62       library library provides a Websock object that is similar to the  stan‐
63       dard  WebSocket  object  but Websock enables communication with raw TCP
64       sockets (i.e. the binary stream) via websockify. This  is  accomplished
65       by base64 encoding the data stream between Websock and websockify.
66
67       Websock  has  built-in  receive queue buffering; the message event does
68       not contain actual data but is simply a notification that there is  new
69       data  available.  Several rQ* methods are available to read binary data
70       off of the receive queue.
71
72       The Websock API is documented on the websock.js API wiki page:
73
74       https://github.com/kanaka/websockify/wiki/websock.js
75
76       See the "Wrap a Program" section below for an example of using  Websock
77       and websockify as a browser telnet client (wstelnet.html).
78
79
80   Additional websockify features
81       These are not necessary for the basic operation.
82
83
84       *      Daemonizing: When the -D option is specified, websockify runs in
85              the background as a daemon process.
86
87
88       *      SSL (the wss:// WebSockets URI): This is detected  automatically
89              by  websockify  by  sniffing the first byte sent from the client
90              and then wrapping the socket if the data starts with  '\x16'  or
91              '\x80' (indicating SSL).
92
93
94       *      Flash  security policy: websockify detects flash security policy
95              requests (again by sniffing the first packet) and  answers  with
96              an  appropriate  flash security policy response (and then closes
97              the port). This means no separate flash security  policy  server
98              is needed for supporting the flash WebSockets fallback emulator.
99
100
101       *      Session  recording:  This  feature  that allows recording of the
102              traffic sent and received from the client to a  file  using  the
103              --record option.
104
105
106       *      Mini-webserver:  websockify can detect and respond to normal web
107              requests on the same port as  the  WebSockets  proxy  and  Flash
108              security  policy.  This functionality is activate with the --web
109              DIR option where DIR is the root of the web directory to serve.
110
111
112       *      Wrap a program: see the "Wrap a Program" section below.
113
114
115   Wrap a Program
116       In addition to proxying from a  source  address  to  a  target  address
117       (which  may  be  on  a different system), websockify has the ability to
118       launch a program on the local system and proxy WebSockets traffic to  a
119       normal TCP port owned/bound by the program.
120
121       The  is  accomplished with a small LD_PRELOAD library (rebind.so) which
122       intercepts bind() system calls by the program. The  specified  port  is
123       moved to a new localhost/loopback free high port. websockify then prox‐
124       ies WebSockets traffic directed to the original port to the new (moved)
125       port of the program.
126
127       The  program  wrap mode is invoked by replacing the target with -- fol‐
128       lowed by the program command line to wrap.
129
130       `./websockify 2023 -- PROGRAM ARGS`
131
132       The --wrap-mode option can be used to indicate what action to take when
133       the wrapped program exits or daemonizes.
134
135       Here  is  an  example of using websockify to wrap the vncserver command
136       (which backgrounds itself) for use with noVNC:
137
138       `./websockify 5901 --wrap-mode=ignore -- vncserver  -geometry  1024x768
139       :1`
140
141       Here  is  an  example  of  wrapping telnetd (from krb5-telnetd).telnetd
142       exits after the connection closes so the wrap mode is  set  to  respawn
143       the command:
144
145       `sudo ./websockify 2023 --wrap-mode=respawn -- telnetd -debug 2023`
146
147       The  wstelnet.html  page  demonstrates a simple WebSockets based telnet
148       client.
149
150
151

AUTHOR

153       Joel Martin (github@martintribe.org)
154
155

SEE ALSO

157       https://github.com/kanaka/websockify/
158
159       https://github.com/kanaka/websockify/wiki/
160
161
162
163
164version 0.3                      June 7, 2012                    websockify(1)
Impressum