强制https访问格式

用amh搭建的网站,测试使用https访问。安装了ssl模块后,给网站添加ssl证书。使用自签名的证书,更改vhost/*.conf文件

ssl模块在最后添加的

#------SSL BEGIN
listen       443;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/cs.myfreehost.ga.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/cs.myfreehost.ga.pem;
#------SSL END
}

其中listen       443;删掉
更改最前面部分

server
{
	listen       80;
	server_name cs.myfreehost.ga; #server_name end
    rewrite ^/(.*) https://$host/$1 permanent;}
server
{
	listen       443;
	server_name cs.myfreehost.ga; #server_name end
        index index.html index.htm index.php; #index end

后面的不用修改,这样就可以了。


已发布

分类

作者:

标签

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注