Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The method of windows installation nginx deployment reverse proxy and load balancing

Shulou Source: shulou.com Published: 2022-05-31 12:11:37 09月23日 Update

Most people do not understand the knowledge points of this article "windows installation nginx deployment reverse proxy and load balancing method", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "windows installation nginx deployment reverse proxy and load balancing method" article.

Download and install nginx (the environment of this article is windows xp 32bit environment)

Extract the nginx-1.0.11.zip, enter nginx-1.0.11, and execute the command on the command line to start nginx. The specific operation is as follows:

To test whether the installation is successful, enter the address:

The browser displays the results as shown below:

The ok,nginx deployment was successful.

Second, about the reverse proxy configuration of nginx.

Reverse proxy (reverse proxy) means that the proxy server accepts the connection request on the internet, then forwards the request to the server on the internal network, and returns the result obtained from the server to the client requesting the connection on the internet. At this time, the proxy server is externally represented as a server.

Regarding the configuration of reverse proxy for nginx, take Baidu Google as an example, the configuration file nginx.conf (path: d:\ nginx\ nginx-1.0.11\ nginx-1.0.11\ conf) is as follows:

The copy code is as follows:

Location / baidu {

Proxy_pass http://www.google.com;

Proxy_set_header host $host

Proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for

}

Where "/ baidu" is mapped to "http://www.google.com"".

Test access:

Access results:

Although the interface displays errors, the effect has been achieved.

Third, load balancing test.

There are two tile service addresses. Use nginx as a load balancer. The configuration file is as follows:

The copy code is as follows:

Upstream cluster {

Server 192.98.12.60:1985 weight=3 max_fails=2 fail_timeout=30s

Server 192.98.12.42:8086 weight=3 max_fails=2 fail_timeout=30s

}

Server {

Listen 8090

Server_name localhost

# charset koi8-r

# access_log logs/host.access.log main

Location / {

Root html

Index index.html index.htm

}

Location / tileservice {

Proxy_pass http://cluster/mongotileservice/tileservice;

Proxy_set_header host $host

Proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for

}

Once configured, nginx-s reload address: you can get the service image:

The above is the content of this article on "windows installation nginx deployment reverse proxy and load balancing method". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about the relevant knowledge, please follow the industry information channel.

Tags: Agent service configuration content balance server code method address result test success command file article environment knowledge article two value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS MySQL Shulou Tech Info Redmi