nginx http重定向https nginx http重定向https配置说明

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

nginx http重定向https nginx http重定向https配置说明

  2021-03-24 我要评论
想了解nginx http重定向https配置说明的相关内容吗,在本文为您仔细讲解nginx http重定向https的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:nginx,http重定向https,nginx,https,下面大家一起来学习吧。

nginx http重定向https配置说明

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

使用

安装

yum install nginx -y

配置

cat /etc/nginx

server {
 listen 80;
 server_name dounine.com www.dounine.com;
 return  301 https://www.dounine.com$request_uri;
}
server {
 listen 443;
 server_name dounine.com dounine.com;
 return  301 https://www.dounine.com$request_uri;
}
server {
 listen 443;
 server_name www.dounine.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://127.0.0.1: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.dounine.com、dounine.com与https://dounine.com 重定向至https://www.dounine.com地扯中。

注意

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

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们