网站地址由http转为https的方法

本文详细介绍如何在阿里云服务器上配置HTTPS,包括下载证书文件、修改nginx配置及重启服务等步骤,帮助读者实现网站安全连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目中采用的是阿里云服务器,想换成https,需要在阿里云中去下载两个文件

1、282314911__ceshi.cn.key

2、282314911__ceshicn.pem

需要将这两个文件放在服务器上面的nginx文件的nginx.conf文件同级

下面是nginx的设置:

upstream project{
    session_sticky mode=insert option=indirect;
    server 127.0.0.1:1011;

    check interval=3000 rise=2 fall=2 timeout=1000 type=http;
    check_http_send "HEAD /jkv2.jsp HTTP/1.0\r\n\r\n";
    check_http_expect_alive http_2xx http_3xx;
}

server {
        listen       443 ssl;
        server_name  www.ceshi.cn;

        ssl on;

        ssl_certificate      /opt/nginx/conf/282314911__ceshi.pem;
        ssl_certificate_key  /opt/nginx/conf/282314911__ceshi.cn.key;
                                                                                                                                                                               
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
        location ~* \.(html|htm|shtml|zip|rar|doc|docx|xls|xlsx|ppt|ppts|gif|jpg|jpeg|png|bmp|swf|ico|js|css)$ {
                root /data/ceshi;
        }
        location /  {
                proxy_set_header Host $host:80;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_redirect  off;
                session_sticky_hide_cookie upstream=web_s;
                proxy_pass http://project;
        }
    }

 

然后重启nginx

/opt/nginx/sbin/nginx -t

/opt/nginx/sbin/nginx -s reload

即可生效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值