LoginSignup
21
20

More than 5 years have passed since last update.

CoreOSでnginxを動かしつつサブドメイン込みでLet's Encryptする

Last updated at Posted at 2016-02-02

はじめに

本記事は、

の合わせ技になります。

普段はDockerで動かしているいくつものサブドメインに対してリバースプロキシしてるサーバーなのですが、今回はリバースプロキシの設定は出てきません。

また、ドメインは既に持っていて、nginxのサーバーが動いているものとします。
/letsencrypt-dummy-webroot は先に作ってnginxから見えるように設定しておきます。

何がやりたいか

  • nginxを止めずに証明書を更新する(nginxの再起動は後回し)
    • webrootオプションを用いる
  • サブドメインごとに面倒な設定をしない

手順

今回はいらないオプションが付いてますが、とくに問題がないのでこのままで。

redirects.conf
server {
    listen      80;
    server_name .example.com;
    location ^~ /.well-known/ {
        root   /letsencrypt-dummy-webroot;
        index  index.html; # これいらないか
    }

    location / {    
        return      301 https://$host$request_uri;
    }
}
core@core ~ $ docker run -it --rm \
-v "/etc/letsencrypt:/etc/letsencrypt" \
-v "/var/lib/letsencrypt:/var/lib/letsencrypt" \
-v "/letsencrypt-dummy-webroot:/var/www" \ quay.io/letsencrypt/letsencrypt:latest certonly \
--webroot --renew-by-default --email root@example.com \
--agree-tos --rsa-key-size 4096 --redirect \
-w /var/www --domains=example.com,sub1.example.com,sub1.example.com
21
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
20