发布于 2017-05-17 06:34:15 | 121 次阅读 | 评论: 0 | 来源: 网友投递
这里有新鲜出炉的Nginx开发从入门到精通,程序狗速度看过来!
Nginx WEB服务器
Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
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端口打开。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!