How to install nginx in windows to deploy reverse proxy and load balancing

WBOY
Release: 2023-05-12 14:17:27
forward
1788 people have browsed it

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

Unzip 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:

How to install nginx in windows to deploy reverse proxy and load balancing

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

The browser displays the result as follows:

How to install nginx in windows to deploy reverse proxy and load balancing

ok, nginx deployment was successful.

2. About nginx reverse proxy configuration.

The reverse proxy method refers to using a proxy server to accept connection requests on the Internet, then forwards the request to the server on the internal network, and returns the results obtained from the server to the Internet The client requesting a connection, at this time the proxy server appears as a server to the outside world.

About nginx configuration reverse proxy configuration, take Baidu Google as an example, configuration file nginx.conf (path: d:\nginx\nginx-1.0.11\nginx-1.0.11\conf) configuration content As follows:

Copy code The 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" will be mapped to "http://www.google.com".

Test visit:

Access result:

How to install nginx in windows to deploy reverse proxy and load balancing

Although the interface displays an error, the effect has been achieved.

3. Load balancing test.

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

Copy the code The 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;
}

After configuration, restart (nginx -s reload) address: You can get the service picture:

How to install nginx in windows to deploy reverse proxy and load balancing

The above is the detailed content of How to install nginx in windows to deploy reverse proxy and load balancing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template