阿里云服务器配置https

时间:2023-11-20 15:17:14

第一步 在阿里云控制台找到申请ssl证书的地址(我申请的是阿里云免费的证书,申请完要等申请通过,可能要等待一两天)

第二步下载ssl nginx版本的证书

第三步上传证书(包含.key, .pem这两个文件的文件夹,命名随便)上传到  /usr/local/nginx/conf/ 这个文件夹下面,其他位置无效

第四步 修改当前要加https的.conf文件,修改后的配置如下

server
{
listen 443;
#listen [::]:80;
server_name wx.zphtown.com ;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/wx.zphtown.com; ssl on;
ssl_certificate wx-cert/1457467_wx.zphtown.com.pem;
ssl_certificate_key wx-cert/1457467_wx.zphtown.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
include none.conf;
#error_page 404 /404.html; # Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
} location ~ .*\.(js|css)?$
{
expires 12h;
} location ~ /.well-known {
allow all;
} location ~ /\.
{
deny all;
} access_log off;
}
server {
listen 80;
server_name www.zphtown.com;
rewrite ^(.*)$ https:
}

本文参考地址