咨询热线:4006-75-4006

售前:9:00-23:30    备案:9:00-18:00    技术:7*24h

nginx http重定向https配置说明

2017-05-04 17:13:13 12289次

nginx http重定向https配置说明

现在什么苹果,谷歌浏览器请求地扯基本都要求使用https了,如何把原来的http协议重定向到https中呢,这里我们可以使用http反向代理软件nginx。

使用安装

yum install nginx -y


修改配置 

#cat /etc/nginx

内容如下:

server {

 listen 80;

 server_name landui.com www.landui.com;

 return  301 https://www.landui.com$request_uri;

}


server {

 listen 443;

 server_name landui.com landui.com;

 return  301 https://www.landui.com$request_uri;

}


server {

 listen 443;

 server_name www.landui.com;

 ssl on;

 ssl_certificate /etc/nginx/dounine.crt;

 ssl_certificate_key /etc/nginx/dounine.key;


location / {

client_max_body_size 20m;

proxy_pass http://www.landui.com:8080;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

注意以上配置可将www.landui.com、landui.com与https://www.landui.com 重定向至https://www.landui.com地扯中。

记得将防火墙的80与443端口打开。


首页
最新活动
个人中心