業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

FreeBSD15.0 : WebサーバーSSL化、Webminインストール

1. Webサーバー(Apache)SSL化

portsでは更にFreeBSDの定期ジョブ設定による更新が行える。
certbotをpkgでインストールする。webrootモードで更新したいのでapache用のプラグインも入れる。

1.1 Let's Encrypt 用 Certbot ツールのインストール

インストールできるcertbotを検索する

py311-certbot のみインストールできます

以下のコマンドを実行して、CertbotパッケージとApache HTTPプラグインをインストールします

1.2 Apache 設定ファイル編集

①mod_sslモジュールを有効にする
httpsポート追加

1.3 Rewriteモジュールを有効にする

HTTPからHTTPSにリダイレクトする際にURLを変更するために必要

Apache24再起動

1.4 Let's Encrypt証明書の取得

①FreeBSD13.2と同様に下記コマンドで取得しようとしても次のエラーが出てssl moduleを読み込まないので、仕方なく➁の方法で行った
Unable to read ssl_module file; not disabling session tickets.

➁単一ドメイン[FQDN]のみをカバーする証明書を取得するには、以下のcertbotコマンドを実行する:
今回は--standaloneオプションを使い取得しますので、一度apacheを停止します

apache24を起動します

1.5 Apache設定ファイルの編集

①/usr/local/etc/apache24/extra/httpd-ssl.conf の編集
httpd-ssl.confをコピーしてbsd-httpd-ssl.confを作成し、編集する(bsd-httpd-ssl.confのbsd-httpd-sslは任意の名称)

➁bsd-httpd-ssl.conf をApacheに読み込ませるため、シンボリックリンクを作る
Includesディレクトリ内にある*.confファイルがインクルードされる

1.6 HTTP 通信を HTTPS へリダイレクト

バーチャルホスト設定ファイルに下記を追記する

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

2. Webminインストール

Webminは、LinuxなどのUnix系オペレーティングシステム (OS) を設定できるウェブブラウザベースのツールである。 ユーザーやディスク使用上限、サービス、設定ファイル等といったOS内部設定の変更を多数行え、ApacheやPHP、MySQLなどといった多くのオープンソースのアプリケーションの変更や制御を行える。

Webminは主にPerlで構築されており、独自のプロセス、そしてウェブサーバとして動作する。 初期設定では10000番のTCPポートで通信する。

2.1 インストール

2.2 セットアップ

ログインユーザー ; admin
パスワード ; 任意
その他はデフォルトでEnter

以下の要領で初期セットアップを行います。

****************************************** *********
Welcome to the Webmin setup script, version 2.600
***************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.

Installing Webmin in /usr/local/lib/webmin

*****************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.

Config file directory [/usr/local/etc/webmin]: /usr/local/etc/webmin
Log file directory [/var/db/webmin]: /var/db/webmin
******************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.

Full path to perl (default /usr/local/bin/perl): /usr/local/bin/perl

Testing Perl ..
.. done

*******************************************************
Operating system name: FreeBSD
Operating system version: 15.0
********************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :

  • What port to run the web server on. There must not be another
    web server already using this port.
  • The login name required to access the web server.
  • The password required to access the web server.
  • If the web server should use SSL (if your system supports it).
  • Whether to start webmin at boot time.

Web server port (default 10000):
Login name (default admin): [enter]
Login password: [password]
Password again: [password]
Use SSL (y/n): y

**********************************************************
Creating web server config files ..
.. done

Creating access control file ..
.. done

Creating start and stop scripts ..
.. done

Copying config files ..
.. done

Changing ownership and permissions ..
.. done

Running postinstall scripts ..
.. done

Enabling background status collection ..
.. done

2.3 /etc/rc.conf の編集

2.4 起動

起動スクリプトは/usr/local/etc/rc.d/webmin

2.5 WebminのSSL設定

webサーバーのSSL化で取得したLetsencryptets 証明書と秘密鍵を単一の.pemファイルに結合します。(今回はwebmin.pemとします)

webmin.pem 証明書ファイルを Webmin 設定ディレクトリに移動します

Webminのメイン設定ファイルを編集
keyfileの項目を下記の通り書き換えます

webmin再起動

2.6 ログイン

事前にFirewallで10000ポートを開放しておく(ipfw.rulesに追記する)
外部から接続する場合はルータの変更も必要
ブラウザで
https://サーバドメイン名または IP アドレス:10000/にアクセスするとログイン画面が表示されます。
設定しておいたユーザとパスワードでログインします。

Webmin のメイン画面

左メニューで [Webmin] - [Change Language and Theme] をクリックし、右ペインの [Personal choice] から日本語に変更

メニューが日本語に変わりました

タイトルとURLをコピーしました