openresty集群负载均衡,openresty集群
openresty集群负载均衡,openresty集群
1 window下安装
1.1下载
https://github.com/LomoX-Offical/nginx-openresty-windows
1.2 解压启动
解压到 D盘, 打开目录,双击nginx.exe, 没有效果,查看日志 D:\nginx\logs\error.log,发现如下错误:
bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
80端口被占用,可以查看端口占用的进程,然后关闭进程,也可以修改端口。打开D:\nginx\conf\nginx.conf, 修改其中的端口配置,如下:
1.3 验证查看
在浏览器上访问 http://localhost:8081/, 如果出现以下界面,就是成功的:
2 集群
2.1 负载均衡
修改D:\nginx\conf\nginx.conf
upstream dem {
server 127.0.0.1:8080 weight=1;
#server 127.0.0.1:8080 weight=1;
}
server {
listen 8081;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://dem;
}
评论暂时关闭