noVNC + Lighttpd + mod_websocket

549 views
Skip to first unread message

Sebastian Pastor Volosín

unread,
Mar 19, 2018, 4:43:50 AM3/19/18
to noVNC
Hello everybody,

I wanted to share how I was able to setup noVNC with Xvnc (from TightVNC) and lighttpd on a project I'm maintaining. Great job on noVNC, absolutely loved it. I am very far from an expert on these matters, but I hope my little experience here can help other newbies out there that are too afraid to ask.
First I was able to get noVNC working by running websockify as a daemon to proxy from Xvnc's 5901 TCP socket to a websocket on 5902. This worked fine and I was happy about it... until I realized I could get more and avoid the need of having the 5902 port open and could tunnel everything through TCP 80 port. The Python sample with websockify points towards that direction with its simple web-server, but I don't have room for Python in the device.
So I gave a try to lighttpd with mod_websocket plugin. First attempt with websockify running in the background worked fine as well, but when I tried to use mod_websocket's TCP proxy I had to add the "binary" string to the "subproto" for everything to work through the same port. Details are at the end.
Also, I wanted to mention that I had to go to back to lighttpd-1.4.33 in order to mod_websocket to build properly since it doesn't seem to be up to date.

Thanks again. Best regards!

Sebastián.-

The URL I now pass to noVNC is url='ws://<host>/tcp_proxy' 
And the lighttpd.conf looks like:

server.modules += ( "mod_proxy", "mod_websocket" )

server.document-root = "/usr/local/zigor/activa/www/html" 

server.port = 80

mimetype.assign = (
  ".html" => "text/html", 
  ".css" => "text/css",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png",
  ".js" => "text/javascript" 
)

index-file.names = ( "index.html" )

websocket.server = (
                     # WebSocket-TCP Proxy, this connects directly to Xvnc
                     "^\/tcp_proxy\/*" => ( "host" => "localhost",
                                        "port" => 5901,
                                        "proto" => "tcp",
                                        "type" => "binary",
                                        "subproto" => "binary",
                                        ),
                     # This requires websockify to be in the middle forwarding Xvnc 5901 to 5902
                     "^\/websocket\/*" => ( "host" => "localhost",
                                       "port" => 5902,
                                       "type" => "binary",
                                       "proto" => "websocket",
                                        ),

                   )

websocket.ping_interval = 5 # send PING per 5 secs
websocket.timeout = 30      # disconnect a client when not to recv PONG for 30 secs
websocket.debug = 4         # LOG_DEBUG

Pierre Ossman

unread,
Mar 19, 2018, 5:07:59 AM3/19/18
to no...@googlegroups.com, Sebastian Pastor Volosín
On 19/03/18 09:43, Sebastian Pastor Volosín wrote:
> So I gave a try to lighttpd <https://www.lighttpd.net/> with mod_websocket
> <https://github.com/nori0428/mod_websocket> plugin. First attempt with
> websockify running in the background worked fine as well, but when I tried
> to use mod_websocket's TCP proxy I had to add the "binary" string to the
> "subproto" for everything to work through the same port. Details are at the
> end.

This is some unfortunate non-standard behaviour that crept in many
implementations during WebSockets early days. We've tried to move away
from it in noVNC, which can cause some issues. :/

Regards
--
Pierre Ossman Software Development
Cendio AB https://cendio.com
Teknikringen 8 https://twitter.com/ThinLinc
583 30 Linköping https://facebook.com/ThinLinc
Phone: +46-13-214600 https://plus.google.com/+CendioThinLinc

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
Reply all
Reply to author
Forward
0 new messages