- 登陆阿里云账号,进入: SSL证书(应用安全)``
- 购买证书,按要求提交审核,等待签发(半个小时就好)
- 下载证书,一个.pem文件,一个.key文件
- 上传证书,分别上传到nginx/conf/cert/目录下(cert目录自己创建)
- .conf文件配置
- 如果需要同时存在https和http协议,则保留原来的server的配置
server
{
listen 443 ssl;
server_name 域名;
index index.html index.htm index.php;
root 网站根目录;
ssl_certificate cert/***.pem;
ssl_certificate_key cert/***.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}
- 检测配置并重启nginx
nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
systemctl restart nginx.service
- 访问带https协议的的指定域名