在nginx.conf下配置
腾讯云:
http{
#http节点中可以添加多个server节点
server{
#监听443端口
listen 443;
#对应的域名,把yuming.com改成你们自己的域名就可以了
server_name yuming.com;
ssl on;
#从腾讯云获取到的第一个文件的全路径
ssl_certificate /etc/ssl/xxxxxxx.crt;
#从腾讯云获取到的第二个文件的全路径
ssl_certificate_key /etc/ssl/xxxxxxxx.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#这是我的主页访问地址,因为使用的是静态的html网页,所以直接使用location就可以完成了。
location / {
#文件夹
root /usr/local/service/ROOT;
#主页文件
index index.html;
}
}
server{
listen 80;
server_name yuming.com;
rewrite ^/(.*)$ https://yuming.com:443/$1 permanent;
}
}
阿里云
server {
listen 443;
server_name yuming.com; // 你的域名
ssl on;
root /var/www/yuming.com; // 前台文件存放文件夹,可改成别的
index index.html index.htm;// 上面配置的文件夹里面的index.html
ssl_certificate cert/xxxxxx.pem;// 改成你的证书的名字
ssl_certificate_key cert/xxxxxxx.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;
location / {
index index.html index.htm;
}
}
server {
listen 80;
server_name yuming.com;// 你的域名
rewrite ^(.*)$ https://$host$1 permanent;// 把http的域名请求转成https
}