さくら VPS の前段にウェブアクセラレータを置いて Let's Encrypt を設定する

さくらの Web アクセラレータは無料枠のある CDN サービスです。これをさくら VPS の Nginx で運用するサイトの前段において、Let’s Encrypt で SSL 化したときの手順をまとめました。 Let’s Encrypt は certbot ツールが便利なのでこちらをインストールします。 SSL 証明書の発行には、ドメイン認証のために http 経由で http://対象ドメイン/.well-known/acme-challenge/ 下にあるワンタイムトークンを取得できるようにする必要があります。このパスは、https 化した後に http アクセスをリダイレクトする場合も除外するようにしておかないといけません。 Let’s Encrypt で証明書を発行 ルートディレクトリの設定 対象ドメインのルートディレクトリを作成します。 # mkdir /var/www/example.tilfin.net Nginx の設定 対象ドメインの server (http) ディレクティブ内に、下記の location ディレクティブを追加します。Nginx をリロードします。 server { listen 80; server_name example.tilfin.net; ... location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; root /var/www/example.tilfin.net; break; } ... } certbot で証明書を発行 # certbot certonly -d "example.tilfin.net" -w /var/www/example.tilfin.net Saving debug log to /var/log/letsencrypt/letsencrypt.log How would you like to authenticate with the ACME CA? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: Nginx Web Server plugin (nginx) 2: Spin up a temporary webserver (standalone) 3: Place files in webroot directory (webroot) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-3] then [enter] (press 'c' to cancel): ここで 3 を入力します。 ...

2019年9月20日 · Toshimitsu Takahashi