トップ 履歴 一覧 カテゴリ ソース 検索 ヘルプ RSS ログイン

OpenBSD/httpd/68(relayd)

INDEX

OpenBSD Web サーバ (httpd on OpenBSD 6.8 7.0)

OpenBSD の Webサーバ httpd(relayd) で、Webサーバを動かす。

OpenBSD に初期で組み込まれている Web サーバが、Apache 1.3系 から(nginx になって)、OpenBSD 5.6 に独自のもの relayd(8) ベースに変更されている。

CGI の実行は OpenBSD/httpd/68(relayd+slowcgi) を。SSL(TSL) 接続は OpenBSD/httpd/68(relayd+tsl) も参照。

httpd の起動設定

  自動起動

サーバが起動したときに httpd も実行されるように、/etc/rc.conf.localhttpd_flags を指定する。

# httpd web server
httpd_flags=

または、rcctl enable httpd で有効にする( /etc/rc.conf.local に httpd_flags= が記載される)。

  デバッグ

root ユーザのコンソールで、-dvv オプションをつけて実行すると、処理の内容が表示される。

# httpd -dvv
startup
 :後略

Webサーバ(httpd) の設定

/etc/httpd.conf に設定する。サンプルが /etc/examples/httpd.conf にある。

OpenBSD の httpd は、 /var/www に chroot されるようになっている。

  静的ドキュメント

/var/www/htdocs 以下の静的ドキュメントを表示させる(/var/www に chroot され、ドキュメントルートは /htdocs)。

# $OpenBSD: httpd.conf,v 0.00 2021/01/01 00:00:00 xxxxx Exp $

server "default" {
	listen on * port 80

	# Optional, but probably best - change your syslog.conf to do 
	# what you want with it then.
	#log syslog

	root "/htdocs"
	directory auto index
}

# Include MIME types instead of the built-in ones
types {
	include "/usr/share/misc/mime.types"
	# Necessary to ensure patch files show up as text not binary
	text/plain sig
}

  動的ドキュメント

slowcgi を使い CGI を実行させる。OpenBSD/httpd/68(relayd+slowcgi) を参照。

  SSL(TSL) 接続

SSL(TSL) 接続の設定 および ACME client を用いて Let's Encrypt の証明書の取得と更新。OpenBSD/httpd/68(relayd+tsl) を参照。

  リダイレクト

特定の URL のパスにアクセスされた場合に、別ページ もしくは 別サーバにリダイレクトさせる。

「/index.htm」のアクセスを「/index.html」へ、「/example/***」のアクセスを https://example.com/ の同じパス(/example/sample.html を https://example.com/sample.html へ)へリダイレクトさせる。

server "default" {
	# :中略
	location "/index.htm" {
		block return 301 "/index.html"
	}
       location match "/example/(.*)" {
		block return 302 "https://example.com/%1"
	}
	# :中略
}

最終更新時間:2022年02月22日 21時32分11秒 指摘や意見などあればSandBoxのBBSへ。