.Dd Created:2025-10-03|Updated:2025-10-25|| .de ocsi \\$* , .. .de oxr .ocsi .Xr \\$* .. .de oit .It \\$* .. .de obdi .Bl -dash -compact .oit \\$* .. .de obdl .Bd -literal -compact \\$* .. .de onote .Bl -hang -compact .oit \\$* .El .. .de ocomm .Bl -diag -compact .oit \\$* .El .. .de opsy .Pp .Sy - \\$* .. .de obc .Bl -column \\$* .. .de obc2 .obc opt desc .. .de obc3 .obc option arguments description .. .de oce .Bl -column ".Sy enable and start " ".Sy description " .nr i 0 .. .de obci .nr i +1 .It \\ni - \\$* Ta : .. .de oci .oce .obci \\&* .. .Dt CGI oh .Os OpenBSD 7.7| .Nm cgi .Nd configuration and usage .Sh CGI .Ss script .obdi The script needs an interpreter (eg.: #!/bin/ksh). .oit the first output line needs to be 'echo "Content-type: text/html"'. .oit the second output line needs to be empty 'echo \&"\&"'. .oit copy required binaries (including interpreter) to /var/www/bin/. .oit copy dependencies to the corresponding structures in /var/www. .oit binaries and libraries must be owned by www. .El .Ss example .obdl $ whereis grep /usr/bin/grep $ ldd /usr/bin/grep Start End Type Open Ref GrpRef Name 0000030be12e4000 0000030be12ef000 exe 1 0 0 /usr/bin/grep 0000030e32295000 0000030e322b3000 rlib 0 1 0 /usr/lib/libz.so.6.0 0000030eb72e8000 0000030eb73dd000 rlib 0 1 0 /usr/lib/libc.so.96.1 0000030de67ed000 0000030de67ed000 ld.so 0 1 0 /usr/libexec/ld.so $ doas install -o www /usr/lib/libz.so.6.0 /var/www/usr/lib/ $ doas install -o www /usr/libexec/ld.so /var/www/usr/libexec/ .Ed .Ss httpd.conf The location with the cgi scripts needs to have the fastcgi socket defined. .obdl server "default" { ... location "/$CGI_PATH/*" { fastcgi socket "/run/slowcgi.sock" } } .Ed .Sh EXAMPLE .Ss curl This site has the location "/:*" defined and when accessing from curl it will display the ascii version of the files. .obdl location "/:*" { fastcgi { param SCRIPT_FILENAME "$CGI_PATH_FROM_CHROOT/$SCRIPT"} } .Ed .Ss httpd.conf .obdl server "default" { listen on * port 80 root "/htdocs/$DIR" location "/$CGI_PATH/*" { fastcgi socket "/run/slowcgi.sock" } #curl access location "/:*" { fastcgi { param SCRIPT_FILENAME "$CGI_PATH_FROM_CHROOT/$SCRIPT"} } } .Ed .Sh TESTING .Li chroot /var/www No to test the script and ensure all dependencies are available and have the correct permissions. .Sh SERVICES .Bl -enum -compact .oit Test: .Dl doas slowcgi -dnvvv .oit Enable and start .obdl doas rcctl enable slowcgi doas rcctl restart slowcgi .Ed .oit Restart httpd. .El .Sh SEE ALSO .oxr web oh .Xr httpd oh .opsy examples: .ocsi .Lk /cgi/example.cgi figlet example cgi .Lk /cgi/search.cgi search .opsy text files: .ocsi .In /dev/example.cgi .ocsi .In /dev/curl.cgi .In /dev/search.cgi .opsy OpenBSD manpages: .oxr slowcgi 8 .Xr rcctl 8 .El .Ss links .obc2 .It - Lk https://www.fossil-scm.org/home/doc/trunk/www/server/openbsd/fastcgi.md Serving Fossil via httpd on OpenBSD .El .Sh AUTHORS .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com