• 阿里云域名和服务器 nginx 配置https


    1.阿里云购买域名并备案

    2.阿里云服务器,我的系统是ubuntu nginx 

    3.申请SSL证书,申请免费的即可

    4.下载证书,根据自己的系统来,我现在的是nginx版本

    5.把要用的域名指向到服务器IP地址

    6.把下载的证书放到服务器上,目录最好和你的配置文件同级(/etc/nginx/cert)中,也有可能你的配置文件在更深的目录里,自行判断

    7.修改配置文件

    server {
        listen          80;
        listen [::]:80;
        server_name     mts.zhanluo.top;//你的域名
    
        root /var/www/html/project/MTS/public;
        index index.html index.php;
    
        rewrite ^(.*)$ https://$host$1 permanent;//把http的域名请求转成https
    
        location ~ .php$ {
    		include snippets/fastcgi-php.conf;
    	#
    	#	# With php7.0-cgi alone:
    	#	fastcgi_pass 127.0.0.1:9000;
    	#	# With php7.0-fpm:
    		fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    	}
    }
    server {
        listen 443;
        server_name mts.zhanluo.top;//你的域名
        ssl on;
        root /var/www/html/project/MTS/public;//项目路径
        index index.html index.php;
        ssl_certificate  /etc/nginx/sites-available/cert/2285672_mts.zhanluo.top.pem;//证书路径,最好把路径写全了
        ssl_certificate_key /etc/nginx/sites-available/cert/2285672_mts.zhanluo.top.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 ~ .php$ {
    		include snippets/fastcgi-php.conf;
    	#
    	#	# With php7.0-cgi alone:
    	#	fastcgi_pass 127.0.0.1:9000;
    	#	# With php7.0-fpm:
    		fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    	}
    }
    

      配置差不多是这个样子,自己配置的时候配置文件里的中文要去掉,不然有报错

  • 相关阅读:
    几种常用的排序算法
    Charles 抓包工具安装和采坑记录
    当你骂特朗普的时候你究竟在骂什么
    苹果公司的另一面:沃兹尼亚克
    网络爬虫设计中需要注意的几个问题
    微信小程序 canvas 绘图问题总结
    自己动手做智能家居之:智能空调控制
    Allegro导入PADS文件
    C#
    C#
  • 原文地址:https://www.cnblogs.com/huanghanyi/p/10951471.html
Copyright © 2020-2023  润新知