_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
| ohazot | docs | links | dev | conf | txt |
| es | en |
| mdoc file |
| search |
cgi —
configuration and usage
CGI
script
- The script needs an interpreter (eg.: #!/bin/ksh).
- the first output line needs to be 'echo Content-type: text/html '.
- the second output line needs to be empty 'echo ""'.
- copy required binaries (including interpreter) to /var/www/bin/.
- copy dependencies to the corresponding structures in /var/www.
- binaries and libraries must be owned by www.
example
$ 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/
httpd.conf
The location with the cgi scripts needs to have the fastcgi socket defined.
server default {
...
location "/$CGI_PATH/*" {
fastcgi socket "/run/slowcgi.sock"
}
}
EXAMPLE
curl
This site has the location "/:*" defined and when accessing from curl it will display the ascii version of the files.
location /:* {
fastcgi { param SCRIPT_FILENAME "$CGI_PATH_FROM_CHROOT/$SCRIPT"}
}
httpd.conf
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"}
}
}
TESTING
chroot /var/www to test
the script and ensure all dependencies are available and have the correct
permissions.
SERVICES
- Test:
doas slowcgi -dnvvv - Enable and start
doas rcctl enable slowcgi doas rcctl restart slowcgi
- Restart httpd.
SEE ALSO
- examples: figlet example cgi , search
- text files:
</dev/example.cgi>
,
</dev/curl.cgi>
,
</dev/search.cgi>
- OpenBSD manpages: slowcgi(8) , rcctl(8)
links
| - Serving Fossil via httpd on OpenBSD |