Tutorial on deploying multiple servers with WebApi and configuring Nginx load balancing

Tutorial on deploying multiple servers with WebApi and configuring Nginx load balancing

01PARTCoreWebApi tutorial local demonstration environment

Visual Studio2019---Vsersion:16.4.4+NetCore3.1.2

02PARTNginx quickly builds and configures load balancing

Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server released under the BSD-like protocol. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx's concurrency capabilities perform better among web servers of the same type. Users of nginx websites in mainland China include: Baidu, JD.com, Sina, NetEase, Tencent, Taobao, etc.

The following demonstrates the process of configuring Nginx

1. Download the Nginx package: http://nginx.org/en/download.html Note that the path for downloading and storing the Nginx package must be in English and cannot contain Chinese characters;

2. Start Nginx: Just double-click the downloaded Nginx package to open "nginx.exe", or you can start it through the command; the command start is not explained in detail here; after starting, open the task manager, and you will find that there will be Nginx service in the task manager;

3. At this time, you can use Nginx to configure load balancing. I first start multiple WebApi servers and run them. The data returned by the same interface of each server is slightly different. The data returned by the interface of the first server is: Chaoxi Education---1, the data returned by the interface of the second server is: Chaoxi Education---2, and the data returned by the interface of the third server is: Chaoxi Education---3. The ports of the three servers after startup are: 8011, 8022, and 8033 respectively. In other words, the 8011 port returns: Chaoxi Education---1; the 8022 port returns: Chaoxi Education---2; the 8033 port returns: Chaoxi Education---3. In other words, the three server codes are the same, but the results returned here are different, in order to be able to test the difference.

4. After startup, the debugging results are:

http://127.0.0.1:8011/api/First returns: Chaoxi Education---1;

http://127.0.0.1:8022/api/First returns: Chaoxi Education---2;

http://127.0.0.1:8033/api/First returns: Chaoxi Education---3;

Figure 1

Figure 2

Figure 3

5. The test shows that all three services have been started: At this time, I will configure three server Tonggu nginx clusters; configure the configuration files;

Figure 4

Modify the configuration file as follows:

CMD executes the nginx-s reload command; reloads the service; the test is as follows:

6. Request the same address: http://127.0.0.1:8080/api/First three times and get three different results;

Figure 1

Figure 2

Figure 3

Summarize

This is the end of this article about WebApi deployment on multiple servers and Nginx load balancing configuration. For more information about WebApi deployment on multiple servers and Nginx load balancing configuration, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Nginx/Httpd load balancing tomcat configuration tutorial
  • Nginx load balancing configuration, automatic switching mode when downtime occurs
  • Detailed explanation of Nginx configuration parameters in Chinese (load balancing and reverse proxy)
  • Nginx forward and reverse proxy and load balancing functions configuration code example
  • Implementation of Nginx load balancing/SSL configuration
  • Detailed explanation of nginx server installation and load balancing configuration on Linux system
  • How to configure multiple tomcats with Nginx load balancing under Linux
  • Nginx server load balancing and ssl principle, generate ssl key pair, Nginx configuration ssl operation example
  • Detailed explanation of installing nginx server and load balancing configuration in CentOS6.5 environment
  • Nginx load balancing configuration simple configuration method
  • Detailed explanation of Linux system configuration nginx load balancing
  • Analysis of Nginx cluster load balancing configuration process
  • What is Nginx load balancing and how to configure it

<<:  Detailed explanation of the use of HTML canvas and page storage technology in JavaScript

>>:  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Recommend

How to verify whether MySQL is installed successfully

After MySQL is installed, you can verify whether ...

Solution to the cross-domain problem of SpringBoot and Vue interaction

Table of contents Browser Same Origin Policy 1. V...

Detailed tutorial on installing MYSQL under WINDOWS

1. Download the installation package -Choose the ...

Web Design Tutorial (5): Web Visual Design

<br />Previous article: Web Design Tutorial ...

Examples of optimistic locking and pessimistic locking in MySQL

The task of concurrency control in a database man...

A brief discussion on HTML doctype and encoding

DOCTYPE Doctype is used to tell the browser which...

Detailed installation and configuration of hadoop2.7.2 under ubuntu15.10

There are many Hadoop installation tutorials on L...

Nodejs implements intranet penetration service

Table of contents 1. Proxy in LAN 2. Intranet pen...

Pygame code to make a snake game

Table of contents Pygame functions used Creating ...

Installation, activation and configuration of ModSecurity under Apache

ModSecurity is a powerful packet filtering tool t...