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 红包祝福语简短10字
18 周六早晨祝福语简短