Nginx load balancing configuration-the path to nginx learning

Source: Internet
Author: User
: This article mainly introduces nginx server load balancer configuration-the path to nginx learning. if you are interested in the PHP Tutorial, please refer to it. To use server load balancer, you can modify and configure the http node as follows:

# Set the http server and use its reverse proxy function to provide load balancing support for http {# set the mime type, which is determined by mime. the type file defines include/etc/nginx/mime. types; default_type application/octet-stream; # set the log format access_log/var/log/nginx/access. log; # omitting some of the preceding configuration nodes #.......... # Set the upstream mysvr {# The weigth parameter in the server list of server load balancer to indicate the weight. the higher the weight, the higher the probability of being allocated to the server 192.168.8.1x: 3128 weight = 5; # enable port 3128 for Squid on the local machine. it is not required that squid server 192.168.8.2x: 80 weight = 1; server 192.168.8.3x: 80 weight = 6;} upstream mysvr2 {# weigth parameter indicates the weight, the higher the weight, the higher the probability of being allocated to the server. the higher the weight, the higher the server 192.168.8.x: 80 weight = 1; server 192.168.8.x: 80 weight = 6 ;} # The first virtual server {# listens to port 80 of 192.168.8.x listen 80; server_name 192.168.8.x; # server load balancer request location ~ for the aspx suffix ~. *\. Aspx $ {# define the default website root directory location root/root of the server; # define the index name of the home index file. php index.html index.htm; # Redirect requests to the server list defined by mysvr proxy_pass http://mysvr ; # The following are some reverse proxy configurations that can be deleted. proxy_redirect off; # The backend Web server can use X-Forwarded-For to obtain the user's Real IP address proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ bytes; # maximum number of single-file bytes allowed by the client request client_max_body_size 10 m; # maximum number of bytes cached by the buffer proxy client request, client_body_buffer_size 128 k; # nginx and backend server connection timeout (proxy connection timeout) proxy_connect_timeout 90; # After successful connection, backend server response time (proxy reception timeout) proxy_read_timeout 90; # set proxy server (nginx) proxy_buffer_size 4 k; # proxy_buffers buffer. if the average page size is below 32 k, set proxy_buffers to 432 k; # buffer size under high load (proxy_buffers * 2) proxy_busy_buffers_size 64 k; # sets the cache folder size. if the size is greater than this value, proxy_temp_file_write_size 64 k will be uploaded from the upstream server ;}}}

The above introduces the nginx server load balancer configuration-nginx learning path, including some content, hope to be helpful to friends who are interested in PHP tutorials.

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.