mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-16 00:00:07 +01:00
![]() Establish a new distributed CMake architecture with CMake code related to a source directory moving to be in the subdir in its own CMakeLists.txt. In particular, there's now one in ./lib which calls through to ones further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc. This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction, and it's much easier to maintain sub-CMakeLists.txt that are in the same directory as the sources they manage, and conceal all the details that that level. Child CMakelists.txt become responsible for: - include_directories() definition (this is not supported by CMake directly, it passes it back up via PARENT_SCOPE vars in helper macros) - Addition child CMakeLists.txt inclusion, for example toplevel -> role -> role subdir - Source file addition to the build - Dependent library path resolution... this is now a private thing in the child CMakeLists.txt, it just passes back any adaptations to include_directories() and the LIB_LIST without filling the parent namespace with the details |
||
---|---|---|
.. | ||
mount-origin-localhost1 | ||
mount-origin-localhost2 | ||
mount-origin-localhost3 | ||
CMakeLists.txt | ||
minimal-http-server.c | ||
README.md |
lws minimal http server multivhost
This creates a single server that creates three vhosts listening on both :7681 and :7682. Two separate vhosts share listening on :7682.
vhost | listens on port | serves |
---|---|---|
localhost1 | 7681 | ./mount-origin-localhost1 |
localhost2 | 7682 | ./mount-origin-localhost2 |
localhost3 | 7682 | ./mount-origin-localhost3 |
Notice the last two both listen on 7682. If you visit http://localhost:7682, by default you will get mapped to the first one, localhost2.
However if you edit /etc/hosts on your machine and add
127.0.0.1 localhost3
so that you can visit http://localhost3:7682 in your browser, lws will use the
Host: localhost3
header sent by your browser to select the localhost3 vhost
for the connection, and you will be served content from ./mount-origin-localhost3
build
$ cmake . && make
usage
Commandline option | Meaning |
---|---|
-d | Debug verbosity in decimal, eg, -d15 |
--die-after-vhost | For testing failure handling |
$ ./lws-minimal-http-server-multivhost
[2018/03/16 09:37:20:0866] USER: LWS minimal http server-multivhost | visit http://localhost:7681 / 7682
[2018/03/16 09:37:20:0867] NOTICE: Creating Vhost 'localhost1' port 7681, 1 protocols, IPv6 off
[2018/03/16 09:37:20:0868] NOTICE: Creating Vhost 'localhost2' port 7682, 1 protocols, IPv6 off
[2018/03/16 09:37:20:0869] NOTICE: Creating Vhost 'localhost3' port 7682, 1 protocols, IPv6 off
[2018/03/16 09:37:20:0869] NOTICE: using listen skt from vhost localhost2
Visit http://localhost:7681 and http://localhost:7682