Question

I want to make Lighttpd works with websocket (Socket.IO) and it appears the only way to do so is to install an additionnal module: mod_websocket. I followed these steps but I think I don't get the right /path/to/lighttpd_top_srcdir. I used /usr/lib/lighttpd as I saw all the modules in here when I ls-ed it. Apparently, I need to reinstall Lighttpd, am I right?

So far, I got

copy mod_websocket files into /usr/lib/lighttpd
cp src/mod_websocket*.{h,c} /usr/lib/lighttpd/src
cp: target « /usr/lib/lighttpd/src » is not a directory

I need to do this because the error I get when trying to make websockets work is the following: WebSocket connection to 'ws://<myURL>/socket.io/1/websocket/agXkznae1gmlDTutzJyk' failed: Unrecognized frame opcode: 5 (I use Google Chrome v33.0.1750.154).

Is there another way to make websockets work with Lighttpd or do I need to change webserver?

Many thanks!

Was it helpful?

Solution

I resolved my problem!

I used HAProxy instead of Lighttpd mod_proxy as specified in this question

Here is my conf file (amend <...> per your configuration):

# this config needs haproxy-1.1.28 or haproxy-1.2.1

global
  log  127.0.0.1  local0
  log  127.0.0.1  local1 notice
  maxconn  4096
  uid  99
  gid  99
  daemon

defaults
  log   global
  mode  http
  option  httplog
  option  dontlognull
  retries  3
  option http-use-proxy-header
  option  redispatch
  option  http-server-close
  maxconn  2000
  contimeout  5000
  clitimeout  50000
  srvtimeout  50000

frontend public
  bind *:80
  acl is_example hdr_end(host) -i <URL.toyourwebsite.com>
  acl is_websocket hdr(Upgrade) -i WebSocket
  acl is_websocket path_beg -i /websockets
  use_backend ws if is_websocket is_example
  default_backend www

backend ws
    balance roundrobin
    option forwardfor # This sets X-Forwarded-For
    timeout queue 5000
    timeout server 86400000
    timeout connect 86400000
    server apiserver localhost:<PORT> weight 1 maxconn 1024 check

And I made Lighttpd listened to the 8080 port (otherwise HAProxy wouldn't start).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top