方向代理:
修改nginx的配置文件
upstream tomcatS{
server http://144.34.134.37:8080;
server http://144.34.134.37:8081
}
server {
listen 88;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass tomcatS;
index index.html index.htm;
}
}
负载均衡:
添加权重weight,默认为1,越高处理的越多
upstream tomcatS{
server http://144.34.134.37:8080 weight=2;
server http://144.34.134.37:8081;
}
server {
listen 88;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass tomcatS;
index index.html index.htm;
}
}
本文详细介绍了如何通过修改Nginx配置文件实现方向代理和负载均衡,包括设置上游服务器组、指定监听端口、配置代理传递路径等关键步骤。同时,还讲解了如何通过设置权重来调整服务器处理请求的比例。
1245

被折叠的 条评论
为什么被折叠?



