管理しているサイトへのアクセスが拒否された…
vpsコントロールパネルの確認
起動中
apacheの確認
# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 木 2021-10-21 19:15:33 JST; 8h left
Docs: man:httpd(8)
man:apachectl(8)
Process: 1098 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 1098 (code=exited, status=1/FAILURE)
10月 21 19:15:30 v157-7-134-162.myvps.jp systemd[1]: Starting The Apache HTTP Server...
10月 21 19:15:33 v157-7-134-162.myvps.jp httpd[1098]: AH00112: Warning: DocumentRoot [/var/www/html/postfixadmin] doe...xist
10月 21 19:15:33 v157-7-134-162.myvps.jp httpd[1098]: (98)Address already in use: AH00072: make_sock: could not bind ...:443
起動もできない…トホホ
# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
問題は2つありそう
1)postfixadminがDocumentRootにない!と怒っている
2)443でSocketがない!と怒っている
apache文法チェック
# apachectl configtest
AH00112: Warning: DocumentRoot [/var/www/html/postfixadmin] does not exist
Syntax OK
文法は問題ないが、やはりpostfixadminがDocumentRootにない!と怒っている
postfixadminをバーチャルドメインの一つのルート直下に入れていた
/var/www/html/example.com/postfixadmin
これがマズイらしい
postfixadminをDocumentRootに移行
mv /var/www/html/example.com/postfixadmin /var/www/html/postfixadmin
移動できていることを確認
# ls /var/www/html/
postfixadmin
http://IPアドレス/postfixadminpublic/login.php
にアクセスし、機能を確認
もう一度Apacheステータス確認
# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 木 2021-10-21 10:53:40 JST; 3min 43s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 8572 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 8572 (code=exited, status=1/FAILURE)
10月 21 10:53:40 v157-7-134-162.myvps.jp systemd[1]: Starting The Apache HTTP Server...
10月 21 10:53:40 v157-7-134-162.myvps.jp httpd[8572]: (98)Address already in use: AH00072: make_sock: could not bind ...:443
443でSocketがない!と怒っている
https://ah-2.com/g1/2014/06/11/yum_update_httpd_fail_restart.html
こちらで/etc/httpd/conf.d/ssl.confが復活して悪さをしていると読み、確認
# ls /etc/httpd/conf.d/
ssl.conf
やはり、以前に削除したssl.confが復活している…
# rm /etc/httpd/conf.d/ssl.conf
rm: 通常ファイル `/etc/httpd/conf.d/ssl.conf' を削除しますか?
y
Apache再起動
# systemctl start httpd
起動した!
# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 木 2021-10-21 11:05:55 JST; 48min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 8631 (httpd)
Status: "Total requests: 92; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─8631 /usr/sbin/httpd -DFOREGROUND
├─8632 /usr/sbin/httpd -DFOREGROUND
├─8633 /usr/sbin/httpd -DFOREGROUND
├─8634 /usr/sbin/httpd -DFOREGROUND
├─8636 /usr/sbin/httpd -DFOREGROUND
├─8637 /usr/sbin/httpd -DFOREGROUND
├─8643 /usr/sbin/httpd -DFOREGROUND
├─8647 /usr/sbin/httpd -DFOREGROUND
├─8652 /usr/sbin/httpd -DFOREGROUND
├─8653 /usr/sbin/httpd -DFOREGROUND
└─8693 /usr/sbin/httpd -DFOREGROUND
10月 21 11:05:54 v157-7-134-162.myvps.jp systemd[1]: Starting The Apache HTTP Server...
10月 21 11:05:55 v157-7-134-162.myvps.jp systemd[1]: Started The Apache HTTP Server.
OK!
ssl.confが復活した理由
「crontab」が悪さをしている可能性あり
# crontab -l
# Update SSL Cert File
0 5 * * 3 /root/bin/update_sslcert.sh 1>> /var/log/update_sslcert.log 2>&1
毎週水曜日午前5時0分に「update_sslcert.sh」というスクリプトを実行させる設定
保存ファイル /var/spool/cron/root
crontab -e
ファイル内容を削除
これで様子を見る
「snap」でも自動更新設定をしている
# snap list
Name Version Rev Tracking Publisher Notes
certbot 1.21.0 1582 latest/stable certbot-eff✓ classic
core 16-2.52.1 11993 latest/stable canonical✓ core
core20 20210928 1169 latest/stable canonical✓ base
「certbot」がLet'sEncryptを設定するプログラム
# snap refresh --time
timer: 00:00~24:00/4
last: today at 22:48 JST
next: tomorrow at 02:51 JST
0時から24時のあいだに4回作動
最後に作動したのが今日22時48分
次に作動するのが明日の2時48分
systemctl list-timers
NEXT LEFT LAST PASSED
火 2021-11-16 06:21:00 JST 6h left 月 2021-11-15 20:32:19 JST 3h 12min ago sn
火 2021-11-16 12:39:13 JST 12h left 月 2021-11-15 12:39:13 JST 11h ago sy
2 timers listed.
Pass --all to see loaded but inactive timers, too.
snapの検証
設定時間とは別に作動させてみる
# /var/lib/snapd/snap/bin/certbot
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/<ドメイン名>/fullchain.pem
Key is saved at: /etc/letsencrypt/live/<ドメイン名>/privkey.pem
This certificate expires on 2022-02-16.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
証明書を正常に受信しました。
証明書は/etc/letsencrypt/live/<ドメイン名>/fullchain.pemに保存されています。
秘密鍵は/etc/letsencrypt/live/<ドメイン名>/privkey.pemに保存されています。
この証明書の有効期限は2022-02-16です。
これらのファイルは、証明書が更新されるときに更新されます。
Certbotは、この証明書をバックグラウンドで自動的に更新するようにスケジュールされたタスクを設定しました。
検証結果
ブラウザでアクセスしたexample.comのSSL証明書は2022年2月16日期限に更新されていた。
アクセス障害はなし。
問題となったssl.confは更新されておらず、ファイル内容は空のまま。