Let's Encrypt是最近很火的一个免费SSL证书发行项目,Let's Encrypt是由ISRG提供的免费免费公益项目,自动化发行证书,但是证书只有90天的有效期。
配置nginx https免费证书
提前安装好nginx
nginx配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.abc.com; #替换成自己的域名
root /www/aaa;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ~ /.well-known {
allow all;
}
location / {
root /www/aaa;
}
}
开始安装证书工具
# yum -y install epel-release
# yum -y install yum-utils
# yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
# yum install python2-certbot-nginx
生成证书
# certbot certonly -a webroot --webroot-path=/www/aaa -d www.abc.com -m 11111@qq.com
生成成功后证书的路径:/etc/letsencrypt/live/www.abc.com
修改nginx配置
server
{
listen 443 ssl;
server_name www.abc.com;
ssl_certificate /etc/letsencrypt/live/www.abc.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.abc.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
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;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ~ /.well-known {
allow all;
}
location / {
root /www/aaa;
}
}
server
{
listen 80;
server_name www.abc.com;
root /var/www/html/lanjingfenqi.com/lanjing_pc;
index index.html;
return 301 https://$host$request_uri;
}