Image by Taken from Pixabay

OpenBSD httpd — Website Maintenance

Create Maintenance Page

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website Under Maintenance</title>
<meta name="description" content="Website Under Maintenance">
<meta name="author" content="phbits">
<style>html, body { height: 100%; font-family: 'Courier'; } .listed-item { display: flex; justify-content: center; align-items: center; }</style>
</head>
<body>
<div class="listed-item">
<h1>Website Under Maintenance</h1>
</div>
</body>
</html>

Update httpd.conf

  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.
public_ip="1.1.1.1"server "website.domain.com" {
listen on $public_ip port 80
directory no auto index
location match "^/maintenance.html$" {
root "/htdocs/website.domain.com"
}
location match ".*" {
block return 302 "https://website.domain.com/maintenance.html"
}
}

Check httpd.conf is valid

httpd -n

Restart httpd

rcctl restart httpd

Test

  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.

 by the author.

--

--

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