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 兄妹拍照祝福语简短的话