• Home
Name Date Size #Lines LOC

..--

mount-origin-localhost1/03-May-2024-150142

mount-origin-localhost2/03-May-2024-149142

mount-origin-localhost3/03-May-2024-149142

CMakeLists.txtD03-May-2024728 2420

README.mdD03-May-20241.5 KiB4935

minimal-http-server.cD03-May-20245.4 KiB188128

README.md

1# lws minimal http server multivhost
2
3This creates a single server that creates three vhosts listening on both :7681 and
4:7682.  Two separate vhosts share listening on :7682.
5
6|vhost|listens on port|serves|
7---|---|---
8localhost1|7681|./mount-origin-localhost1
9localhost2|7682|./mount-origin-localhost2
10localhost3|7682|./mount-origin-localhost3
11
12Notice the last two both listen on 7682.  If you visit http://localhost:7682,
13by default you will get mapped to the first one, localhost2.
14
15However if you edit /etc/hosts on your machine and add
16
17```
18127.0.0.1 localhost3
19```
20
21so that you can visit http://localhost3:7682 in your browser, lws will use the
22`Host: localhost3` header sent by your browser to select the localhost3 vhost
23for the connection, and you will be served content from ./mount-origin-localhost3
24
25## build
26
27```
28 $ cmake . && make
29```
30
31## usage
32
33Commandline option|Meaning
34---|---
35-d <loglevel>|Debug verbosity in decimal, eg, -d15
36--die-after-vhost | For testing failure handling
37
38```
39 $ ./lws-minimal-http-server-multivhost
40[2018/03/16 09:37:20:0866] USER: LWS minimal http server-multivhost | visit http://localhost:7681 / 7682
41[2018/03/16 09:37:20:0867] NOTICE: Creating Vhost 'localhost1' port 7681, 1 protocols, IPv6 off
42[2018/03/16 09:37:20:0868] NOTICE: Creating Vhost 'localhost2' port 7682, 1 protocols, IPv6 off
43[2018/03/16 09:37:20:0869] NOTICE: Creating Vhost 'localhost3' port 7682, 1 protocols, IPv6 off
44[2018/03/16 09:37:20:0869] NOTICE:  using listen skt from vhost localhost2
45```
46
47Visit http://localhost:7681 and http://localhost:7682
48
49