首先在阿里云申请免费的证书,选择自动生成证书。然后就是nginx虚拟主机配置文件的修改。以下是我的配置文件(因为公司开发小程序,没有办法只能使用https)。
您只需要关注带有ssl的配置选项,我增加了一个监听80和443的端口,同时增加了http跳转https的配置
server
{
listen 443;
listen 80;
server_name yasi.baimuv.com;
index index.html index.htm index.php default.html default.htm default.php;
root /data/wwwroot/yasi;
#强制https
if ($scheme = http) {
return 301 https://$host$request_uri;
}
#Https配置区域
ssl on;
ssl_certificate ../cert/214198214130804.pem;
ssl_certificate_key ../cert/214198214130804.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;
#Https配置区域结束
include none.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}如果无法访问请检查:
1.443端口公网是否已经开放
2.证书文件位置是否正确
3.不要怀疑其他问题,基本是你配置不对。
成功后的效果:

Application 对象用于存储和访问来自任意页面的变量,类似 Session 对象。不同之处在于所有的用户分享一个 Application 对象,而 session 对象和用户的关系是一一对应的。很多的书籍中介绍的Application对象都喜欢以统计在线人数来介绍Application 对象...
git pull https://git.oschina.net/392223903/learn.git master 换为您的git地址...
方案1.IE浏览器"无法显示此页"的解决办法(1).按下Win+R键打开运行,输入netsh winsock reset,回车;(2).重启即可. 方案2.IE浏览器"无法显示此页"的解决办法 (1).设置-连接-局域网设置-自动检测设置开...
vsftp常用操作命令:1.启动vsftp: service vsftpd start 2.重启vsftp: service vsftpd restart3.修改用户密码:passwd lao8org4.创建用户:useradd -d /data/wwwroot/blog -s /sbin...
navicat for mysql 11.1.13 企业破解版.绿色软件免安装,请直接打开安装说明.一定要看说明.下载地址: http://pan.baidu.com/s/1dFINxNN下载链接失效,直接点击上方QQ呼叫...