Tomlab WEB server


/etc/httpd.conf
server "hoge.com" {
  listen on nnn.nnn.nnn.nnn port 80
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
  }
  location * {
    block return 302 "https://$HTTP_HOST$REQUEST_URI"
  }
}

server "hoge.com" {
  listen on nnn.nnn.nnn.nnn tls port 443
  hsts
	tls {
		certificate "/etc/ssl/hoge.com.fullchain.pem"
		key "/etc/ssl/private/hoge.com.key"
	}
  location "/cgi-bin/*" {
    fastcgi socket "/run/slowcgi.sock"
    root "/"
  }
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
  }
}
types {
  include "/usr/share/misc/mime.types"
}
/etc/acme_client.conf
authority letsencrypt {
	api url "https://acme-v02.api.letsencrypt.org/directory"
	account key "/etc/acme/letsencrypt-privkey.pem"
}
domain hoge.com {
	domain key "/etc/ssl/private/hoge.com.key"
	domain full chain certificate "/etc/ssl/hoge.com.fullchain.pem"
	sign with letsencrypt
}
2: RUN
doas rcctl enable httpd
doas rcctl start  httpd
doas rcctl enable slowcgi
doas acme-client -v hoge.com && doas rcctl reload httpd

# 以上のコマンドにより、以下の通りに反映
# /etc/rc.conf.local
#   httpd_flags=
#   slowcgi_flags=
doas crontab -e
0	0	*	*	*	acme-client hoge.com && rcctl reload httpd
3: TEST CGI
# /var/www/cgi-bin/test.cgi
echo "Content-type: text/html"
echo ""
echo "CGI TEST WORKING"


doas chmod +x /var/www/cgi-bin/test.cgi

# ローカル端末より	  : curl ipv4/cgi-bin/index.cgi
# ローカルのブラウザより  : http://ipv4/cgi-bin/index.cgi
4: GATHER PROG FILES AND LIBs
# replicate the system's directory structure (recommended)
list1="[ cat date dd echo kill ls mkdir mv rm sh"
list2="awk basename bc cmp diff dirname env find getconf"
list2="$list2 grep head mktemp paste printf sed sort tail"
list2="$list2 tee touch tr uname wc which xargs fold"
list3="bgc fct knum pad rand round codon rc re"
list4="calclock cgi-name cjoin0 cjoin1 cjoin2 delf self fsed seq"
list4="$list4 filehame formhame mojihame mojihame-h mojihame-l"
list4="$list4 mojihame-p nameread mime-read mkcookie mktemp"
list4="$list4 tarr tateyoko up3 yarr keta"

[ -d "/var/www/usr/bin"        ] || doas mkdir -p /var/www/usr/bin
[ -d "/var/www/usr/lib"        ] || doas mkdir -p /var/www/usr/lib
[ -d "/var/www/usr/libexec"    ] || doas mkdir -p /var/www/usr/libexec
[ -d "/var/www/usr/share/misc" ] || doas mkdir -p /var/www/usr/share/misc
[ -d "/var/www/mybin"          ] || doas mkdir    /var/www/mybin

# /bin
printf '%s\n' $list1 |
while read i ; do
  doas cp  /bin/$i /var/www/bin/$i
done

# /usr/bin
printf '%s\n' $list2 |
while read i ;do
  doas cp /usr/bin/$i /var/www/usr/bin/$i
done

# /usr/lib  /usr/libexec
printf '%s\n' $list2  |
sed 's;^;/usr/bin/;'  |
xargs ldd 2&/dev/null |
awk '{print $7}'      |
grep lib              |
sort -u               |
while read i ; do
  doas cp $i /var/www$i
done

# /usr/share/misc/bc.library
doas cp /usr/share/misc/bc.library /var/www/usr/share/misc/

# /mybin
printf '%s\n' $list3 |
while read i ;do
  doas cp ~/.CMD/$i /var/www/mybin/$i
done

printf '%s\n' $list4 |
while read i ;do
  doas cp ~/.CMD/.ShellShoccar/$i /var/www/mybin/$i
done

# /tmp /dev (for: /dev/null) /logs/cgi
[ -d "/var/www/tmp" ] || doas mkdir -p /var/www/tmp
[ -d "/var/www/dev" ] || doas mkdir -p /var/www/dev
[ -d "/var/www/logs/cgi" ] || doas mkdir -p /var/www/logs/cgi
doas chmod 777 /var/www/tmp
doas chmod 777 /var/www/dev
doas chmod 777 /var/www/logs/cgi
5: APPENDICS: path reference in CGI Script