sslあてる
SSL化(無料)
Saba note 取得ツールのインストール
ssh foo cd /usr/local/ git clone https://github.com/certbot/certbot cd certbot/ ./certbot-auto -n
SSL発行
[root@foo]#./certbot-auto certonly --webroot \ > -w /home/foo/approot/public -d foo.com \ > -m foo@foo.com \ > --agree-tos -n Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator webroot, Installer None Obtaining a new certificate Performing the following challenges: http-01 challenge for foo.com Using the webroot path /home/foo/approot/public for all unmatched domains. Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/foo.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/foo.com/privkey.pem Your cert will expire on 2018-10-03. 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
以下のディレクトリに証明書類が作成されていることを確認
[root@foo]#ll /etc/letsencrypt/archive/foo.com/ total 16 -rw-r--r-- 1 root root 2155 Jul 5 12:02 cert1.pem -rw-r--r-- 1 root root 1647 Jul 5 12:02 chain1.pem -rw-r--r-- 1 root root 3802 Jul 5 12:02 fullchain1.pem -rw-r--r-- 1 root root 1704 Jul 5 12:02 privkey1.pem [root@foo]#
ssl.confを開く
cd /etc/httpd/conf.d/ cp -p ssl.conf ssl.conf.def vi ssl.conf
編集内容
DocumentRoot "/home/foo/approot/public" ServerName foo.com:443 SSLCertificateFile /etc/letsencrypt/archive/foo.com/cert1.pem SSLCertificateKeyFile /etc/letsencrypt/archive/foo.com/privkey1.pem SSLCertificateChainFile /etc/letsencrypt/archive/foo.com/chain1.pem
確認
systemctl restart httpd systemctl status httpd
https://foo.com にアクセスしてみる。
アクセスできなかった。。。
原因追跡
- ssl.confには
/etc/letsencrypt/live/
以下のエイリアスを指定すべき。 /var/log/httpd/ssl_*_log
を確認する。/etc/httpd/
にSSLの実際の鍵のあるフォルダのシンボリックリンクを作る。
cd /etc/httpd ln -s /etc/letsencrypt/archive/foo.com foo
シンボリックリンクの削除はunlink
で行う。
* ssl.confのDirectoryセクションは、基本的にはvirtual.confからコピペしてくる。
ssl.confのサンプル(変更点のみ)
#NameVirtualHost *:443 #NameVirtualHost _default_:443 #<VirtualHost _default_:443> <VirtualHost *:443> DocumentRoot /home/foo/approot/public ServerName foo.com:443 SSLCertificateFile /etc/letsencrypt/live/foo.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/foo.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/foo.com/chain.pem <Directory /home/foo/approot/public> Options All AllowOverride All Require all granted </Directory>
CentOS7のhttpd設定で詰まった点
最近のCentOSではservice
ではなくて、systemctl
を使う。
Let's Encrypt以外の原因を検討
firewallの443(https)に穴を開ける。
# httpsがあるか確認 netstat -a | grep https firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --reload
SELinuxの無効化
getenforce Disabled
Laravel側の対応
.envのAPP_URLをs付きのものに変更し、確認