Nginx详解:https://www.cnblogs.com/yxlblogs/p/3898990.html
如何将 Nginx 配置为Web服务器的方法:https://www.jb51.net/article/107975.htm
nginx超详细讲解之概述:https://blog.youkuaiyun.com/u014459326/article/details/53364849
Nginx反向代理配置:
#user root owner; #在mac中获取权限时需要将注释去掉
worker_processes 2; #启动进程,通常设置成和cpu的数量相等,任务管理器会有三个nginx进程,个人认为其中一个为守护进程
events {
worker_connections 1024; #单个后台worker process进程的最大并发链接数
}
http {
include mime.types; #设定mime类型,类型由mime.type文件定义
default_type application/octet-stream;
#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy)来输出文件,对于普通应用,
#必须设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络I/O处理速度,降低系统的uptime.
sendfile on;
keepalive_timeout 65; #连接超时时间
server {
listen 8080; #侦听8080端口
server_name localhost; # 定义使用www.xx.com访问
charset utf-8;
location / {
proxy_pass http://localhost/thinkphpDome/index.php/Home/index/index;#需要被代理的网址
index index.html index.htm;
}
}
server {#另一个被代理的服务器
listen 8081; #侦听8081端口
server_name localhost; # 定义使用www.xx.com访问
charset utf-8;
location / {
proxy_pass https://www.baidu.com;#需要被代理的网址
index index.html index.htm;
}
}
}
该配置实现的功能:
当输入http://localhost:8080链接地址时,此时浏览器会访问http://localhost/thinkphpDome/index.php/Home/index/index链接地址。感觉像是实现了路由功能。
注:可以配置多台服务器
只需在多加server{.......}配置即可。
反向代理的作用:https://www.jianshu.com/p/ab44b933a68f
个人的理解:当10000个请求同时请求同一个接口,正向代理是应付不来的,那么可以实行的方案,我在10个服务器上同时部署用户需要请求的接口,然后通过代理服务器随机分配给10个服务器,那么每个服务器只需承担1000个请求了。
Nginx负载均衡配置:https://www.cnblogs.com/qlqwjy/p/8536779.html