Nginx load balancing configurationIt is also relatively simple to configure load balancing using nginx First, configure the address corresponding to the virtual domain name in the http block # Load balancing upstream myserver { server 127.0.0.1:8080; server 127.0.0.1:8082; } Then configure the listener in the server block server { listen 9000; server_name localhost; location / { root html; index index.html index.htm; # Corresponding to the name proxy_pass http://myserver configured in the upstream above; ### The following are minor items of concern proxy_set_header Host $host; proxy_method POST; #Specify the header field that is not forwarded proxy_hide_header Cache-Control; #Specify the forwarding header field proxy_pass_header Server-IP; # Whether to forward the package body proxy_pass_request_body on | off; # Whether to forward headers proxy_pass_request_headers on | off; # Visible/invisible URI, when upstream redirection occurs, whether Nginx changes the URI synchronously proxy_redirect on | off; } } In this way, when accessing the server using port 9000, load calls will be made to port 8080 and 8082. Nginx load balancing strategy Polling (default)Distribute them to different servers one by one in chronological order. If the backend server crashes, they will be automatically deleted. WeightWeight represents the weight, the default value is 1, the larger the weight, the more requests are allocated # Load balancing upstream myserver { server 127.0.0.1:8080 weight=1; server 127.0.0.1:8082 weight=2; } ip_hashEach request is hashed according to the accessed IP address, so that each visitor accesses a certain server, which can solve the session problem. # Load balancing upstream myserver { ip_hash; server 127.0.0.1:8080; server 127.0.0.1:8082; } fair (third party)Assign according to the response time of the request, which server responds faster is assigned to whom The above is the details of how to configure load balancing in Nginx. For more information about configuring load balancing in Nginx, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: Pure CSS to achieve the water drop animation button in Material Design
>>: Vue realizes the function of book shopping cart
Because colleagues in the company need Nginx log ...
Preview versions of Safari (Technology Preview 10...
student.xml <?xml version="1.0" enco...
Table of contents Introduction question Design 1:...
Table of contents 1. Cartesian product phenomenon...
Sometimes we may encounter such a requirement, th...
Table of contents Since Vuex uses a single state ...
Use blockquote for long citations, q for short ci...
1. Open the CentOS 7 virtual machine. 2. Log in t...
Recently Microsoft released Windows Server 2016, ...
1. Use floating method Effect picture: The code i...
Recently I saw an article on a public account tha...
Table of contents 1. Install ESXi 2. Set up ESXi ...
environment name property CPU x5650 Memory 4G dis...
1. Why is eject not recommended? 1. What changes ...