.Dd Created:$Mdocdate$ .Dt ohazot_httpd .Tg back_to_top .Bd -literal -compact _ _ ___ | |__ __ _ _______ | |_ / _ \\| '_ \\ / _` |_ / _ \\| __| | (_) | | | | (_| |/ / (_) | |_ \\___/|_| |_|\\__,_/___\\___/ \\__| .Ed .Tg menu .Bl -column ".Sy ohazot " ".Sy ohazot " ".Sy ohazot " .It Xr ohazot oh Ta | .Xr docs oh Ta | .Xr about oh Ta .El .Dd Created:2025-10-03|Updated:2025-10-06 .Dt ohazot_httpd .Os OpenBSD .Nm httpd .Nd OpenBSD httpd configuration .Sh IMPORTANT .Sx back_to_top All commands need to be executed with root. .Sh TOC .Sx back_to_top .Bl -column -offset indent "Sy directory listing " .It Sx CONFIGURATION .It - Sx httpd.conf .It - Sx directory listing .It - Sx authentication .It - Sx mime types .It Sx HTTPD .It - Sx testing .It - Sx rcctl .It Sx EXAMPLE .It Sx TODO .It Sx SEE ALSO .El .Sh CONFIGURATION .Sx back_to_top .Bl -enum -compact .It Copy the examples .Pa httpd.conf to /etc: .Dl cp /etc/examples/httpd.conf /etc/ .It Create the server directory: .Dl mkdir /var/www/htdocs/[SERVER_NAME] .El .Ss httpd.conf .Em defaults .Bl -column -offset indent ".Sy roff_supported (oh) " .It chroot Ta : /var/www .It root Ta : /var/www/htdocs .It directory index Ta : index.html .El .Bd -literal -compact server "default" { listen on * port 80 root "/htdocs/[SERVER_NAME]" } .Ed .Ss directory listing This configuration goes inside the server block. .Bd -literal -compact location "/[DIR_LIST_PATH]/*" { directory auto index } .Ed .Ss authentication .Bl -enum -compact .It Create the authentication file in /var/www: .Bd -literal -compact htpasswd /var/www/[SERVER_NAME]_htpasswd [USER] .Ed .It Ensure the file is owned by www: .Bd -literal -compact chown www:www /var/www/[SERVER_NAME]_htpasswd .Ed .It Add the location block with authention: .Bd -literal -compact location "/[LOGIN_LOCATION]/" { authenticate "realm" with "[SERVER_NAME]_htpasswd" } .Ed .Ss mime types .Bd -literal -compact types { text/css css text/html text/plain txt oh sh awk bc image/gif gif image/jpeg jpeg jpg image/png png application/xml xml } .Ed .Sh HTTPD .Sx back_to_top .Ss testing Ensure the configuration is correct, both should return (ok) or inform an error and line number. .Bd -literal -compact httpd -dvvvvvv .Ed Add -n to only verify the config file without running the server. .Ss rcctl .Bd -literal -compact rcctl enable httpd #needs to run after each change rcctl restart httpd .Ed .Sh EXAMPLE .Sx back_to_top .Bd -literal -compact server "default" { listen on * port 80 root "/htdocs/[SERVER_NAME]" location "/[DIR_LIST_PATH]/*" { directory auto index } errdocs "[ERRORS_DIRECTORY]" #location for errors, such as 404.html, 403.html, 503,html, etc. } types { text/css css text/html html text/plain txt oh sh awk bc } .Ed .Sh TODO .Sx back_to_top .Bl -bullet -compact .It Add rewrite. .It Add example for directory index. .It Add chroot example. .It Check mime type log as it gave a syntax error at some point. .It Add better errors section. .El .Sh SEE ALSO .Sx back_to_top .Xr cgi oh .Ss OpenBSD manpages .Xr httpd 8 , .Xr httpd.conf 5 , .Xr rcctl 8 .Ss links .Bl -bullet -compact .It .Lk https://githubhelp.com/reyk/httpd OpenBSD httpd .It .Lk https://www.fossil-scm.org/home/doc/trunk/www/server/openbsd/fastcgi.md Serving Fossil via httpd on OpenBSD: .It .Lk https://dev.to/nabbisen/setting-up-openbsds-httpd-web-server-4p9f Setting Up OpenBSD's httpd Web Server .El .Ss files .In httpd.oh .Sh AUTHORS .Sx back_to_top .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com