Image by Taken from Pixabay

OpenBSD httpd — Website Maintenance

The default web server in OpenBSD is httpd. A lightweight server with only the essentials and built secure from the ground up.

There are occasions when a website must be placed into maintenance and httpd.conf makes this easy with pattern matching.

Tested on: OpenBSD 6.6 GENERIC

Save the following (or similar) page to the website root as maintenance.html.

This technique will redirect all requests which is why no other files are referenced. Any styles or scripts must be specified directly in the maintenance page or hosted on a different website.

Update the target website in httpd.conf as follows. The first location match will correctly display maintenance.html. All other requests will be picked up by the second location match resulting in a redirect to the maintenance page.

Two points worth pointing out about this method are:

  1. Will redirect any request NOT for maintenance.html (e.g. favicon.ico, images, css, js, etc.).
  2. HTTP 302 is being used as the redirect since it is temporary and thus shouldn't impact search engine placement.

Always a good idea to check that httpd.conf is valid after making a change.

With a valid httpd.conf, restart httpd.

Test the new configuration by ensuring the following two points are true.

  1. Requests to website.domain.com/maintenance.html successfully displays the maintenance page.
  2. All other requests to website.domain.com result in an HTTP 302 Found and redirect to the maintenance page.

--

--

https://phbits.com/about/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store