ref: 12cbd60630f854d103b916b3e6f51b1cbda5810c
dir: /rc-httpd.ms/
This guide explains how to provide a simple setup for rc-httpd to serve static web pages. First, copy the template for tcp80 from /bin/service/!tcp80: cpu% cp (/bin/service/)^(!tcp80 tcp80) Next, create the FS_ROOT, the directory which is used to serve web documents: cpu% mkdir -p /usr/$user/www/example.com Add some files: cpu% echo "Hello, world!" > /usr/$user/www/example.com/index.html Put this in /rc/bin/rc-httpd/select-handler: if(~ $SERVER_NAME example.com){ PATH_INFO=$location FS_ROOT=/usr/$user/www/$SERVER_NAME exec static-or-index } cpu% chmod +x /rc/bin/rc-httpd/select-handler This tells rc-httpd to serve static files or an index file upon web requests with the proper FS_ROOT. To support TLS: cpu% cp (/bin/service/)^(!tcp80 tcp443) Inside /bin/service/tcp443, we put: #!/bin/rc exec tlssrv -c /sys/lib/tls/acmed/example.com.crt -r`{cat $3/remote} /rc/bin/rc-httpd/rc-httpd >>[2]/sys/log/www cpu% chmod +x /bin/service/tcp443 Make sure to store the private key into secstore's factotum, so that it gets loaded automatically upon boot: cpu% ramfs -p; cd /tmp cpu% auth/secstore -g factotum secstore password: cpu% cat /sys/lib/tls/acmed/example.com.key >> factotum cpu% auth/secstore -v -p factotum secstore password: cpu% read -m factotum > /mnt/factotum/ctl