windows nginx负载均衡

本文主要介绍在windows平台下,用Nginx部署服务器,负载均衡;

1.下载nginx:http://nginx.org/en/download.html

2.启动nginx 服务:

 执行 start nginx.exe指令:如下 

   

3.新建netCore程序 iis部署,分别对应8051,8052端口;

4.配置Nginx.conf文件,如下:

 #服务器的集群
    upstream  nginxtest.com {  #服务器集群名字		
		server    127.0.0.1:8051 weight=1;#服务器配置   WEIGHT是权重的意思,权重越大,分配的概率越大。	
		server    127.0.0.1:8052 weight=1;
	}

    server {
        listen       8050;#监听8050端口
        #server_name localhost nginxtest.com;
	server_name localhost;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
	       proxy_pass http://nginxtest.com;
               proxy_redirect default;

        }

5:运行结果:

  

 

 

 其中,图二是对应的8051端口的测试程序,图三对应的8052测试程序;

PS:需要注意本地或者服务器安装的netcore hosting版本,否则可能导致503错误;

猜你喜欢

转载自www.cnblogs.com/SecondSun/p/12736387.html