因域名需要使用https访问,决定申请阿里云免费SSL证书并使用nginx配置http强制跳转https。
二、具体步骤
1、登录阿里云账户,在首页搜索框中模糊搜索SSL,选择SSL证书
2、点击购买证书选项
3、点击免费型DV_SSL,购买
5、填写证书申请信息
6、下载nginx形式的证书
nginx中进行配置
1、下载并安装nginx
2、nginx安装目录下新建cert文件夹,将下载的证书解压放在/etc/nginx/root/cert目录下
3、进入nginx/conf文件夹中,编辑配置文件
server {
listen 443 ssl;
server_name www.test.club;
ssl_certificate /etc/nginx/root/cert/4106728_www.ljflxcx.club.pem;
ssl_certificate_key /etc/nginx/root/cert/4106728_www.ljflxcx.club.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 / {
root html;
index index.html index.htm;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://103.66.66.66:18881;
}
}
server {
listen 80;
server_name www.test.club;
rewrite ^(.*) https://$server_name$1 permanent;
}