Let's encryptでSSL証明書の取得(ubuntu20.04+nginx+certbot)
4430 ワード
同様の記事があるのは自明なので、完全なる備忘録。
環境は以下。
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$ nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
ざっくり確認できるように、解説はだいぶ略します。
Install
sudo apt install certbot python3-certbot-nginx
Get
sudo apt install certbot python3-certbot-nginx
初回はたしかメアドとか聞かれたはず。
sudo certbot --nginx -d example.com
Config
nginxのConfig。私は /etc/nginx/conf.d
にあった。
適当にいじりつつ、落ち着いたところ。managed by Certbot
がついてるやつはCertbotが勝手に書いてくれたやつを流用してます。
httpにアクセスされたらhttpsにリダイレクトするおまけつきです。
私はGoでアプリケーションサーバを立てて、リバースプロキシとして動かしてるので、locationはそういう仕様です。
default.conf
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server{
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:xxxx;
}
}
Author And Source
この問題について(Let's encryptでSSL証明書の取得(ubuntu20.04+nginx+certbot)), 我々は、より多くの情報をここで見つけました https://qiita.com/pgDora56/items/e4414da0991aafd40cf3著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .