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

Detailed steps for iis+nginx to implement load balancing

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Brief description: the brief introduction of nginx self-Baidu.

Objective: to distribute users' requests to each server to reduce the pressure. On average, nginx redirects requests from listening ports to the server where the website is deployed.

Install nginx on windows

1. Download the windows version of nginx http://nginx.org/en/docs/windows.html on the official website

The latest version is 1.13.2.

two。 After downloading and decompressing

3. Because port 80 of my computer is already in use, modify the configuration file to listen on port 8080

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

5. When you try to open http://localhost:8080/, the following indicates that nginx has been installed successfully.

Second, set up 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 ();}}

two。 Because my nginx is installed in a virtual machine, now deploy a site in iis in the virtual machine, port: 9000

3. Deploy a site locally, port: 9001

3. Modify the nginx configuration file

1. Add upstream (server cluster) under the http node. Server sets up the information of the cluster server. I have built two sites here and configured two messages.

two。 Find the location node modification under the http node

Location / {

Root html

Index Home/Index index.html index.htm; # change the home page to Home/Index

# where jq_one corresponds to the cluster name set by upstream

Proxy_pass http://Jq_one;

# set the host header and the real address of the client so that the server can obtain the real IP of the client

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 configuration file:

3. Restart Nginx

Enter the command nginx-s reload enter

Complete restart

IV. Verification

Try to access the listening port 8080 and refresh it several times.

Turn Nginx into a service and start it on.

1. With the help of a gadget winsw https://github.com/kohsuke/winsw/releases

Download the simple configuration and. Net environment files, according to your own environment, here under .net4

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

two。 Modify the configuration file

3. Installation service

Enter the command myapp.exe install installation service

You already have nginx in the service, and then you can start the service.

Done.

Reference: a simple deployment tutorial for Nginx+IIS

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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

Servers

Wechat

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

12
Report