这里分享一个自制的简易web server,根据一些开源代码拼凑而成,不但支持http协议,还支持https协议,供感兴趣的朋友参考。
$ ./ycwebserver.exe -h ycwebserver (built on Mar 27 2020) (C)2020 yichen (yichen@wdyichen.cn) Usage: ycwebserver -h : display this help screen -v : log status/error info -p : specifiy http port [default 80] -r : specify http document directory [default wwwroot] -l : specify log file -m : specifiy max clients [default 32] -M : specifiy max clients per IP -s : specifiy download speed limit in KB/s [default: none] -n : disallow multi-part download [default: allow] -d : disallow directory listing [default ON] -c : specify CA file -t : specify cert file -k : specify key file
只有加了-c file -t file -k file才能当作https服务器使用,否则只是个http服务器。
代码是Makefile编译,在shell下敲make即可完成编译。
无论在linux shell还是windows cygwin下都可以编译,其它方式请自行修改。