[Libwebsockets] Configuration questions.

Andy Green andy at warmcat.com
Mon Nov 15 05:33:00 CET 2021

On 11/14/21 20:13, Steve Calfee wrote:

>     No those are just the demo pieces that are installed from the package.
>     You can put your own mounts anywhere (selinux permitting).
> OK, so the conf.d/json file says where it should go. But my sysadmin 
> confusion continues, where is _lws_ddir_ defined? I cannot find it in 
> the source and I am using the

The substitution is here, it becomes LWS_INSTALL_DATADIR


> /home/calfee/Projects/libweb/libwebsockets/lwsws/etc-lwsws-conf.d-localhost-EXAMPLE:
>     12       "mounts": [{
>     13         "mountpoint": "/",
>     14:        "origin": "file://_lws_ddir_/libwebsockets-test-server",
> and it is described, but not explained how to change in

Yes it's an example that wants to work out of the box after lws install. 
  To do it crossplatform, it can't embed unix-style paths in the conf 
file, if eg, it was installed on Windows.  So _lws_ddir_ was invented 
just to conceal that detail.

But this _lws_ddir_ symbolic reference to LWS_INSTALL_DATADIR is just an 
lws example preoccupation, your implementation would not normally use 
any assets from there but put things in your own explicit dirs.

As to how it works, LWS_INSTALL_DATADIR is set by the normal cmake way 
to decide that, the linkage is made in ./cmake/lws_config.h.in


You can control that at cmake-time with


and at make install time, by setting DESTDIR (very handy for packaging)

sudo make DESTDIR=./staging install

puts everything in ./staging/usr/...

>     there are several other mounts and some other vhosts in there for stuff
>     on different ports etc.
>     If you want your user to access these dirs casually, you can set the
>     dir
>     owner to your user, and the group to whatever lwsws-specific group you
>     created, and permissions to 0750.  Then you can copy things into there
>     as the owning user just fine, so long as the files have o+r permission
>     lwsws will be able to read them.
>     If you are not building for permessage-deflate, it is off by default
>     and
>     you can ignore it.
> If I am planning to be passing utf-8 json, is deflate a desirable 
> option? What does permessage-deflate for and why is it off? How would I 
> turn it on (I presume some cmake option).

I don't recommend it.  You can enable it at cmake with 
-DLWS_WITHOUT_EXTENSIONS=0, lwsws has the necessary boilerplate to 
enable it further at runtime if it is enabled at cmake.

>     Incoming stuff passed to the protocol will be chunked at that size, and
>     by default so will what is written out (you can control that
>     independently at the next arg if it is nonzero).  So it affects memory
>     usage and throughput if the protocol has bulk data.
>     -Andy
> If I ever get this working, are you open to a contribution of a new 
> plugin protocol for a simple json exchange, maybe extendable for games? 
> I am (for testing) extending also test.{js,html} too.

I would suggest looking closely at the mirror protocol example.  Because 
making it robust against flooding as well as handling many users, is not 
that straightforward.  You might find you will get better results basing 
off or just straight out using the mirror example, it distributes 
whatever it receives, utf-8 or whatever.


More information about the Libwebsockets mailing list