10分钟构建全站 https
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04
欢迎访问我的站点: daydaygo.top
我的配置:
腾讯云 , Ubuntu 14.04, nginx 1.10
# 下载 letsencryptsudo apt-get -y install git bcsudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt # 使用 git pull 更新即可# nginxsudo apt-get install nginx # 可以添加 nginx 官方源, 安装最新版 nginx# 使用 letsencrypt webroot 模块获取证书cd /opt/letsencrypt./letsencrypt-auto certonly -a webroot --webroot-path=/home/ubuntu/www -d example.com -d www.example.com/etc/letsencrypt/archive/example.com/ # 为站点申请到的证书/etc/letsencrypt/live/example.com/ # 指向生效证书的软链接openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048# 配置 nginx# HTTP serverserver { listen 80; server_name example.com www.example.com; return 301 https://$host$request_uri;}# HTTPS serverserver { listen 443 ssl; server_name example.com www.example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # allow only the most secure SSL protocols and ciphers, and use the strong Diffie-Hellman group ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_stapling on; ssl_stapling_verify on; add_header Strict-Transport-Security max-age=15768000; location / { root /usr/share/nginx/html; index index.html index.htm; } # Add to SSL server block location ~ /.well-known { allow all; }}# 自动获取证书30 2 * * 1 /opt/letsencrypt/letsencrypt-auto renew >> /var/log/le-renew.log35 2 * * 1 /path/to/nginx -s reload