_                    _
  ___ | |__   __ _ _______ | |_
 / _ \| '_ \ / _` |_  / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
 \___/|_| |_|\__,_/___\___/ \__|

httpdOpenBSD httpd configuration

back_to_top

All commands need to be executed with root.

back_to_top

CONFIGURATION
- httpd.conf
- directory listing
- authentication
- mime types
HTTPD
- testing
- rcctl
EXAMPLE
TODO
SEE ALSO

back_to_top

  1. Copy the examples httpd.conf to /etc:
    cp /etc/examples/httpd.conf /etc/
  2. Create the server directory:
    mkdir /var/www/htdocs/[SERVER_NAME]

chroot : /var/www
root : /var/www/htdocs
directory index : index.html
server "default" {
listen on * port 80
	root "/htdocs/[SERVER_NAME]"
}

This configuration goes inside the server block.

location "/[DIR_LIST_PATH]/*" {
	directory auto index
}

  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"
    }

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
}

back_to_top

Ensure the configuration is correct, both should return (ok) or inform an error and line number.

httpd -dvvvvvv
Add -n to only verify the config file without running the server.

rcctl enable httpd
#needs to run after each change
rcctl restart httpd

back_to_top

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
}

back_to_top

back_to_top

cgi

httpd(8) , httpd.conf(5) , rcctl(8)

<httpd.oh>

back_to_top

ohazot | about | ohazot.com <admin@ohazot.com>

Created:2025-10-03|Updated:2025-10-06 OpenBSD