nginx http重定向https配置说明
nginxhttp重定向https配置说明
现在什么苹果,谷歌浏览器请求地扯基本都要求使用https了,如何把原来的http协议重定向到https中呢,这里我们可以使用http反向代理软件nginx。
使用
安装
yuminstallnginx-y
配置
cat/etc/nginx
server{
listen80;
server_namedounine.comwww.dounine.com;
return301https://www.dounine.com$request_uri;
}
server{
listen443;
server_namedounine.comdounine.com;
return301https://www.dounine.com$request_uri;
}
server{
listen443;
server_namewww.dounine.com;
sslon;
ssl_certificate/etc/nginx/dounine.crt;
ssl_certificate_key/etc/nginx/dounine.key;
location/{
client_max_body_size20m;
proxy_passhttp://127.0.0.1:8080;
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
}
}
以上配置可将www.dounine.com、dounine.com与https://dounine.com重定向至https://www.dounine.com地扯中。
注意
记得将防火墙的80与443端口打开。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短