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

How to realize Nginx load balance under Ubuntu

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to achieve Nginx Load Balancer under Ubuntu", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "How to achieve Nginx Load Balancer under Ubuntu"!

When enterprises solve the problem of high concurrency, there are generally two processing strategies: software, hardware, adding a Load Balancer to distribute a large number of requests on hardware, and adding solutions to the bottleneck of high concurrency in software: database +web server. The most common load adding solution in the first layer of web server is to use nginx to implement Load Balancer. environment

ubuntu 16.04.3 LTS

ginx version: nginx/1.10.3 (Ubuntu)

Note: Some parameters in this article are for reference only. Please change them according to the actual environment.

Load Balancer Configuration root@ubuntu-vhost:vim /etc/nginx/sites-enabled/defaultupstream domain.com { server 172.xxx.xxx.xx:80 max_fails=1 fail_timeout=120s; server 172.xxx.xxx.xx:80 max_fails=1 fail_timeout=120s;}server { listen 80; server_name www.domain.com domain.com; location / { proxy_next_upstream http_500 http_502 http_503 http_504 http_404; proxy_connect_timeout 30s; proxy_read_timeout 30s; proxy_pass http://domain.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr; proxy_redirect default; }}

#############################################################

Description:

max_failures =1 fail_timeout=120s; Used to determine the status of backend nodes. Two parameters are used, specified by proxy_next_upstream or fastcgi_next_upstream. Also, proxy_connect_timeout and proxy_read_timeout can be used to control upstream response times. proxy_next_upstream http_500 | http_502 | http_503 | http_504 |http_404; When one of them returns error code 404,500... When an error occurs, it can be assigned to the next server program to continue processing and improve the success rate of platform access. It can be applied to the foreground program load proxy_read_timeout. Please refer to the max_execution_time option value in php.ini. I believe that everyone has a deeper understanding of "How to implement Nginx Load Balancer under Ubuntu". Let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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

Development

Wechat

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

12
Report