さくらVPS契約してみた その3

3. 日本語化

  • ログの監視に logwatch 入れたほうが良いかな?
  • →メール送信するなら、sendmail なり、 postfix なりいるな…
  • → yum list でpostfix入ってるか確認しようとしたら、ロケールがどうのこうのというエラーが出てきた。

ということで、日本語環境が入っていないと何かと不便そうなので、さくらVPSのマニュアルを参照して、日本語環境を設定。

# dnf -y install langpacks-ja
# localectl set-locale LANG=ja_JP.utf8
# localectl
   System Locale: LANG=ja_JP.utf8
       VC Keymap: jp
      X11 Layout: jp

これで、yum list でエラーが出ることはなくなった。

結局、postfix も sendmail も入っていないようだった。

# yum list installed | grep postfix
# (何も出ない)
# yum list installed | grep sendmail
# (何も出ない)

4. メールサーバー

4.1. ドメイン関連

メールサーバーを立ててメールをやり取りするには、まずドメインをVPSに向けないことには始まらないので、ひとまず取得だけしてまだ使ってないドメインをVPSに向けてみる。

使っているDNSはムームードメインのDNSなので、以下のように設定する。

サブドメイン 種別 内容 優先度
mail A (VPSのグローバルIP)  
  MX (使うドメイン) 10

4.2. パケットフィルタの設定

ポートの開放はVPSのコンパネ側で行っているので、そちらがわでメール用のポートを開ける。

さくらVPSでは、「フィルタの用途」で「メール」を選べば、必要なポートは全てセットで開放される。(25/110/143/465/587/993/995 の各ポート)

4.3. Let’s Encrypt の導入

疎通だけなら不要かもしれないが、今後の実運用を考えれば、SSL化はできたほうが良いので、このタイミングで設定。

4.3.1. EPELリポジトリの追加

certbot というのを使って証明書を取得するのだが、そのパッケージがEPELリポジトリに行かないと無いので、リポジトリを追加しておく。

$ sudo dnf install epel-release
メタデータの期限切れの最終確認: 0:57:01 時間前の 2020年11月15日 21時05分50秒 に実施しました。
依存関係が解決しました。
========================================================================================================================
 パッケージ                      アーキテクチャー          バージョン                   リポジトリー              サイズ
========================================================================================================================
インストール中:
 epel-release                    noarch                    8-8.el8                      extras                     23 k

トランザクションの概要
========================================================================================================================
インストール  1 パッケージ

ダウンロードサイズの合計: 23 k
インストール済みのサイズ: 32 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
epel-release-8-8.el8.noarch.rpm                                                         256 kB/s |  23 kB     00:00
------------------------------------------------------------------------------------------------------------------------
合計                                                                                     47 kB/s |  23 kB     00:00
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備              :                                                                                               1/1
  インストール中    : epel-release-8-8.el8.noarch                                                                   1/1
  scriptlet の実行中: epel-release-8-8.el8.noarch                                                                   1/1
  検証              : epel-release-8-8.el8.noarch                                                                   1/1

インストール済み:
  epel-release-8-8.el8.noarch

完了しました!

4.3.2. certbotクライアントのインストール

下記サイトを参考にやったがエラー。

https://www.geekfeed.co.jp/geekblog/centos8_mailserver_1

Let’s Encryptの設定方法は情報が乱立しているので、精査したほうが良い?

もしくは、「No valid IP addresses」とか出てるので、DNS情報が浸透しきってないのが原因?

依存パッケージでいろいろ入ってしまったので、OSから入れ直したほうが早いか・・・?

# dnf -y install postfix dovecot cyrus-sasl cyrus-sasl-plain
# systemctl enable postfix
# systemctl enable dovecot
# systemctl enable saslauthd

# git clone https://github.com/certbot/certbot
# cd certbot
# ./certbot-auto -n
(中略)
インストール済み:
  augeas-libs-1.12.0-5.el8.x86_64
  keyutils-libs-devel-1.5.10-6.el8.x86_64
  krb5-devel-1.17-18.el8.x86_64
  libcom_err-devel-1.45.4-3.el8.x86_64
  libffi-devel-3.1-21.el8.x86_64
  libkadm5-1.17-18.el8.x86_64
  libselinux-devel-2.9-3.el8.x86_64
  libsepol-devel-2.9-1.el8.x86_64
  libverto-devel-0.3.0-5.el8.x86_64
  openssl-devel-1:1.1.1c-15.el8.x86_64
  pcre2-devel-10.32-1.el8.x86_64
  pcre2-utf16-10.32-1.el8.x86_64
  pcre2-utf32-10.32-1.el8.x86_64
  platform-python-devel-3.6.8-23.el8.x86_64
  python-rpm-macros-3-38.el8.noarch
  python3-pip-9.0.3-16.el8.noarch
  python3-rpm-generators-5-6.el8.noarch
  python3-setuptools-39.2.0-5.el8.noarch
  python3-virtualenv-15.1.0-19.module_el8.1.0+245+c39af44f.noarch
  python3-wheel-wheel-1:0.31.1-2.module_el8.1.0+245+c39af44f.noarch
  python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64
  python36-devel-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64
  zlib-devel-1.2.11-16.el8_2.x86_64

完了しました!
./certbot-auto has insecure permissions!
To learn how to fix them, visit https://community.letsencrypt.org/t/certbot-auto-deployment-best-practices/91979/
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Missing command line flags. For non-interactive execution, you will need to specify a plugin on the command line.  Run with '--help plugins' to see a list of options, and see https://eff.org/letsencrypt-plugins for more detail on what the plugins do and how to use them.
# ./certbot-auto certonly --standalone -d country-road.work -m test@country-road.work
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for country-road.work
Waiting for verification...
Challenge failed for domain country-road.work
http-01 challenge for country-road.work
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: country-road.work
   Type:   dns
   Detail: No valid IP addresses found for country-road.work

DNS情報の浸透を待って、もう一度やってみた。今度はうまく行ったっぽい。

# ./certbot-auto certonly --standalone -d country-road.work -m test@country-road.work
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for country-road.work
Waiting for verification...
Cleaning up challenges
Subscribe to the EFF mailing list (email: test@country-road.work).

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/country-road.work/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/country-road.work/privkey.pem
   Your cert will expire on 2021-02-14. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

が、あまりにも分かってない状態で手探り状態。今回はメールサーバー用の証明書を取得する手順をなぞってみたが・・・

  • 同じドメインでWebサーバーをSSL化するのに同じ証明書で良いのか?
  • ドメインを追加する場合にはどうするのか?
  • 参考サイトはrootで作業していたが、管理用の一般ユーザーでは出来るのか?

などなど、分からない点が多い。

ひとまず、メールサーバーやWebサーバーを立てるだけ立てておいて、そっちがうまく行ってからSSL化しても良いのかもしれない。

が、変に運用始めてから設定して、うまく行かずにやり直したい・・・となったときが面倒くさそうなので、やっぱり最初にやっといた方が良いか・・・

さくらVPSだったら、SiteGuard Server Edition も使えるし、そういったセキュリティ対策も最初のうちにやっといたほうが良いだろうし。

もうちょっとググるなり、スタートアップスクリプトの内容チェックするなりして、調べてみるか・・・

コメントはまだありません

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA