nginx http重定向https配置说明
2019/7/10 21:01:08
本文主要是介绍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://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端口打开。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
这篇关于nginx http重定向https配置说明的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?