首页 > Web开发 > 详细

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

时间:2019-05-30 20:09:31      阅读:120      评论:0      收藏:0      [点我收藏+]

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;
	}
}

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

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

原文:https://www.cnblogs.com/huanghanyi/p/10951471.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!