_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
ohazot | | docs | | about |
httpd
—
OpenBSD httpd configuration
IMPORTANT
All commands need to be executed with root.
TOC
CONFIGURATION |
- httpd.conf |
- directory listing |
- authentication |
- mime types |
HTTPD |
- testing |
- rcctl |
EXAMPLE |
TODO |
SEE ALSO |
CONFIGURATION
- Copy the examples httpd.conf to /etc:
cp /etc/examples/httpd.conf /etc/
- Create the server directory:
mkdir /var/www/htdocs/[SERVER_NAME]
httpd.conf
chroot | : /var/www |
root | : /var/www/htdocs |
directory index | : index.html |
server "default" { listen on * port 80 root "/htdocs/[SERVER_NAME]" }
directory listing
This configuration goes inside the server block.
location "/[DIR_LIST_PATH]/*" { directory auto index }
authentication
- Create the authentication file in /var/www:
htpasswd /var/www/[SERVER_NAME]_htpasswd [USER]
- Ensure the file is owned by www:
chown www:www /var/www/[SERVER_NAME]_htpasswd
- Add the location block with authention:
location "/[LOGIN_LOCATION]/" { authenticate "realm" with "[SERVER_NAME]_htpasswd" }
mime types
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
testing
Ensure the configuration is correct, both should return (ok) or inform an error and line number.
httpd -dvvvvvv
rcctl
rcctl enable httpd #needs to run after each change rcctl restart httpd
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 { text/css css text/html html text/plain txt oh sh awk bc }
TODO
- Add rewrite.
- 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
OpenBSD manpages
links
files
<httpd.oh>