{
    分享网正式开通,我们为大家提供免费资源,欢迎大家踊跃投稿!

nginx http重定向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://12.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端口打开。


资源均来自第三方,谨慎下载,前往第三方网站下载


米微资源分享网 , 版权所有丨本站资源仅限于学习研究,严禁从事商业或者非法活动!丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:nginx http重定向https配置说明
喜欢 ()分享 (0)