人间蒸发的gravatar头像
人间蒸发 2020-03-24 14:24:19
http升级https,nginx配置!

原因

http为啥升级成为https,此处就不再多说了。

升级所需环境

1.有一台自己的服务器。

2.有自己的域名。

3.ssl认证证书。

4.nginx,并且支持ssl,比较新的版本都会有的!

证书申请

阿里云官网搜索ssl证书。购买步骤如下图。

http升级https,nginx配置!

过个半小时左右就会签发完成。

下载证书

http升级https,nginx配置!

解压之后是一个pem和key的文件。

把它上传到服务器起下

http升级https,nginx配置!

nginx配置

    server {
        listen       443 ssl;
        server_name  你的域名;
		
	ssl_certificate      cert/ce.pem;
        ssl_certificate_key  cert/ce.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
	
        location  / {
	    root /usr/local/nginx/html;
            try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
		

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	#http强制转到https
	server {
        listen 80;
        server_name 你的域名;
        rewrite ^(.*)$ https://$host$1 permanent;
	}

昨天配置的时候,自己出了点小问题,以为升级会对反向代理有影响,其实没有半毛关系~


打赏

已有2人打赏

已注销用户的gravatar头像 最代码官方的gravatar头像
最近浏览
Uting  LV3 2023年2月21日
youwuzuichen  LV10 2022年5月27日
ch榆罔  LV4 2022年2月23日
wgwyqq  LV10 2022年1月7日
crazy11crazy  LV30 2021年2月24日
wangdongtai  LV31 2021年2月6日
LiXin1994  LV1 2020年12月9日
AaronDjc  LV3 2020年9月25日
master_guo  LV7 2020年9月8日
487948123  LV8 2020年8月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友