Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize load balancing in iis+nginx

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces iis+nginx how to achieve Load Balancer related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe everyone will read this iis+nginx how to achieve Load Balancer article will have some gains, let's take a look at it together.

Purpose: to distribute user requests to various servers to reduce stress. Nginx forwards requests for listening ports evenly to servers where the website is deployed.

Install nginx on Windows

1. Download Windows version of nginx

The latest version is 1.13.2.

2. Download and extract

3. since port 80 of my compute is already in use, modify that configuration file to listen on port 8080

4. Double-click the main program to run, you can see that nginx is already running in the process.

5. Try to open http://localhost:8080/The following appears, indicating that nginx installation is successful

Building two identical sites

1. The website has only one home page.

public class homecontroller : controller { // get: home public actionresult index() { list info = new list(); info.add("Server name:" + server.machinename); info.add("Client ip address:" + (request.userhostaddress=="::1" ? "127.0.0.1":request.userhostaddress)); info.add("http port:" + request.url.port); viewbag.info = info; return view(); } }

2. Because my nginx is installed in the virtual machine, now the virtual machine in iis deployment of a site, port:9000

3. Deploy a site locally, port:9001

Third, modify the nginx configuration file

1. Add upstream (server cluster) under http node, server is set to cluster server information, I set up two sites here, configured with two pieces of information.

2. Find the location node modification under http node

location / {

root html;

index home/index.html index.htm; #Change home page to home/index

#where jq_one corresponds to the cluster name of the upstream setting

proxy_pass http://jq_one;

#Set the host header and client real address so that the server can get the client real ip

proxy_set_header host $host;

proxy_set_header x-real-ip $remote_addr;

proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;

}

Modified profile:

3. restart nginx

Enter the command nginx -s reload Enter

Complete restart

IV. Verification

Try to access port 8080 for listening, refresh the watch a few times

5. Turn nginx into a service and boot it up

1. With the help of a small tool winsw

Download simple configuration and. net environment two files, according to their environment, here under. net4

Then put it in any directory, here with nginx, and change the two files to the same name.

2. modify the configuration file

3. installation services

Enter the command myapp.exe install to install the service

At this point, there is already nginx in the service, and then start the service

About "iis+nginx how to achieve Load Balancer" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of "iis+nginx how to achieve Load Balancer" knowledge. If you still want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report