HTTPD(oh) LOCAL HTTPD(oh) httpd - OpenBSD httpd configuration NOTE: All commands need to be executed with root. 1. Copy the examples httpd.conf to /etc, if it doesn't exist: cp /etc/examples/httpd.conf /etc/ 2. Create the server directory: mkdir /var/www/htdocs/[SERVER_NAME] httpd.conf defaults chroot : /var/www root : /var/www/htdocs directory index : index.html server default { listen on * port 80 root "/htdocs/[SERVER_NAME]" } locations - location /location/ will apply to the directory. - location /location/* will also apply to subdirectories. directory listing This configuration goes inside the server block. location /[DIR_LIST_PATH]/* { directory auto index } authentication 1. Create the authentication file in /var/www: htpasswd /var/www/[SERVER_NAME]_htpasswd [USER] 2. Ensure the file is owned by www: chown www:www /var/www/[SERVER_NAME]_htpasswd 3. Add the location block with authention: location /[LOGIN_LOCATION]/* { authenticate "realm" with "[SERVER_NAME]_htpasswd" } mime types types { include "/usr/share/misc/mime.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 } HTTPD 1. Ensure the configuration is correct. httpd -dvvvvvv Add -n to only verify the config file without running the server. 2. Enable the httpd service: rcctl enable httpd 3. Restart httpd after any change to /etc/httpd.conf: rcctl restart httpd If there is an error, it will show the line number, otherwise, it returns (ok). REWRITE Example: when a document is not found in the spanish section, it will take the user to the english document. location not found match /es/(.*) { request rewrite "/%1" } EXAMPLE 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 { include "/usr/share/misc/mime.types" text/css css text/html html text/plain txt oh sh awk bc } TODO - Improve rewrite example. - Add example for directory index. - Add chroot example. - Check mime type log as it gave a syntax error at some point. - Add better errors section. SEE ALSO web(oh) , openbsd(oh) , cgi(oh) - config example files: - OpenBSD manpages: httpd(8) , httpd.conf(5) , rcctl(8) links - OpenBSD httpd: https://github.com/reyk/httpd - Serving Fossil via httpd on OpenBSD:: https://www.fossil-scm.org/home/doc/trunk/www/server/openbsd/fastcgi.md - Setting Up OpenBSD's httpd Web Server: https://dev.to/nabbisen/setting-up-openbsds-httpd-web-server-4p9f - BSDHowTo.ch - How to setup a web server with OpenBSD: https://www.bsdhowto.ch/webserver.html - roman zolotarev - Configure httpd(8) on OpenBSD: https://romanzolotarev.com/openbsd/httpd.html AUTHORS ohazot(oh) | about(oh) | ohazot.com: https://ohazot.com OpenBSD 7.7| Created:2025-10-03|Updated:2025-10-23| HTTPD(oh)