upstream hostpath {
server 127.0.0.1:9501;
server 127.0.0.1:9503;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
if (!-e $request_filename) {
#proxy_pass http://127.0.0.1:9501;
proxy_pass http://hostpath;
}
}
修改nginx.conf,在里面加入红色部分代码
博客给出了Nginx配置负载均衡的代码示例,通过修改nginx.conf文件,添加相关代码实现。代码中定义了upstream模块指定后端服务器,在server模块中使用proxy_pass将请求转发到指定的后端服务器组。
1087

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



