Nginx ~ Add Server Load balancer for docker containers, nginxdocker

Source: Internet
Author: User

Nginx ~ Add Server Load balancer for docker containers, nginxdocker

As the most popular Server Load balancer and reverse proxy server, Nginx runs on linux. to achieve traffic distribution and load balancing, You need to deploy on IIS of multiple application servers, use some tools to synchronize code, and then configure them on nginx.
With docker, you can run it in one second on multiple linux systems without deploying it on iis. For docker, nginx deployment is more convenient!
Next, let's take a look at the standard Nginx configuration file.

We can add a conf configuration file for each website, and then include the files when nginx is loaded. You don't need to pay attention to them. Haha, let's take a look at their standard content.

Server {listen 8080; server_name localhost; location/{proxy_pass http: // api; proxy_set_header Host $ host: 8080; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;} upstream api {server 192.168.200.108: 5000 weight = 1; server 192.168.200.108: 5001 weight = 1; # high weight}

The server node mainly configures information about the website. proxy_pass is the domain name and port for external Website access. When an upstream node exists, it is the name of the node and listen is the listening port!

The upstream node is the Server Load balancer information of the website. You can set the number of sites in the cluster. Of course, the data synchronization between these websites is not required for nginx!

When an application encounters a problem, we can view the log files, access. log and error. log, as shown in the following directory:

They will record the clients when they visited our website, the websites with loads, and so on. The log information is useful for future data analysis!

Thank you for reading this article!

I hope this article will help you!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.