Conohaのサーバを更新したので、DNS関係をやり直した。
お名前.comで管理している独自ドメインの詳細からネームサーバー情報をConohaのネームサーバアドレスに更新。
実際に更新が反映されるまでしばらく待って、ConohaコントロールパネルのDNSからドメインを登録する。前段階のネームサーバアドレスが更新されていないとドメインは登録できない。また、V2.0のDNSにドメインが登録されていても登録できないようだ。
その後は実際にサーバアドレスを登録する。
Conoha VPSではセキュリティグループを追加して、804423のポート開放をしておく。
サーバでも、ufwなどでポート開放を行う。
その後、pacman -S nginx certbot-nginxをインストールして、let’s encryptを設定する。
vi /etc/nginx/nginx.confで、http,serverセクションにあるserver_nameをlocalhostからドメイン名に変更。nginx -tで確認するとtypes_hash_max_size 1024;またはtypes_hash_bucket_size 64;を増やせと警告がでるので、httpセクションにtypes_hash_bucket_size 128;を追記。
certbot –nginxを実行して、メールアドレスや同意に回答すると設定終了。
この段階でnginxはバックグラウンドで動いていることが、lsof -i:80で確認できる。
ここでsystemctl start nginxを実行すると、下記のエラーとなる。
bind() to 0.0.0.0:443 failed (98: Address already in use)
ブラウザから、https://domain.com/でアクセスすると、nginxのメッセージが表示される。
https://www.ssllabs.com/ssltest/index.htmlでhttps://www.cman.jp/network/support/ssl.htmlにアクセスしてSSLの状態を確認する。
自動更新の設定にはtimerを使用する。
sudio -i; cd /etc/systemd/system
vi certbot.service
[Unit]
Description=Let’s Encrypt renewal
[Service]
Type=oneshot
ExecStart=/usr/bin/certbot renew –quiet –agree-tos –max-log-backups 60 –post-hook “systemctl reload nginx.service”
systemctl start certbot
systemctl status certbotで確認
/var/log/letsencryptにログができ、デフォルトは1000なので制限する。
vi certbot.timer
[Unit]
Description=Weekly renewal of Let’s Encrypt’s certificates
[Timer]
OnCalendar=weekly
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
systemctl start certbot.timer
systemctl status certbot.timer
systemctl enable certbot.timer
systemctl list-timers
Management of own domains

コメント