Simple Nginx server load balancer configuration example

Source: Internet
Author: User
The domain names www.s135.com & nbsp; and blog.s135.com both point to the IP address of the Nginx server. The user access the http://www.s135.com, load balancing its 192.168.1.2: 80, 192.168.1.3: 80, 192.168.1.4: 80, 192.168.1.5: 80 four servers. Use

Www.s135.com? And blog.s135.com domain names all point to the IP address of the Nginx server.

The user access the http://www.s135.com, load balancing its 192.168.1.2: 80, 192.168.1.3: 80, 192.168.1.4: 80, 192.168.1.5: 80 four servers.

The user accesses the http://blog.s135.com and balances its load to ports 8080, 8081, and 8082 of the 192.168.1.7 server.

The configuration file nginx. conf is as follows:

User? Www; worker_processes 10; # error_log? Logs/error. log; # error_log? Logs/error. log? Notice; # error_log? Logs/error. log? Info; # pid???? Logs/nginx. pid; # Maximum file descriptor worker_rlimit_nofile 51200; events {use epoll; worker_connections 51200;} http {include??? Conf/mime. types; default_type? Application/octet-stream; keepalive_timeout 120; tcp_nodelay on; upstream? Www.s135.com ?? {Server? 192.168.1.2: 80; server? 192.168.1.3: 80; server? 192.168.1.4: 80; server? 192.168.1.5: 80;} upstream? Blog.s135.com? {Server? 192.168.1.7: 8080; server? 192.168.1.7: 8081; server? 192.168.1.7: 8082;} server {listen? 80; server_name? Www.s135.com; location/{proxy_pass???? http://www.s135.com ; Proxy_set_header? Host?????? $ Host; proxy_set_header? X-Real-IP???? $ Remote_addr; proxy_set_header? X-Forwarded-? $ Proxy_add_x_forwarded_for;} log_format? Www_s135_com? '$ Remote_addr-$ remote_user [$ time_local] $ request' "$ status" $ response "$ http_referer" ''" $ http_user_agent "$ http_x_forwarded_for"'; access_log? /Data1/logs/www. log? Www_s135_com;} server {listen? 80; server_name? Blog.s135.com; location/{proxy_pass???? http://blog.s135.com ; Proxy_set_header? Host?????? $ Host; proxy_set_header? X-Real-IP???? $ Remote_addr; proxy_set_header? X-Forwarded-? $ Proxy_add_x_forwarded_for;} log_format? Blog_s135_com? '$ Remote_addr-$ remote_user [$ time_local] $ request' "$ status" $ response "$ http_referer" ''" $ http_user_agent "$ http_x_forwarded_for"'; access_log? /Data1/logs/blog. log? Blog_s135_com ;}}

Appendix: for Nginx installation method, refer to Nginx 0.5.31 + PHP 5.2.4 (FastCGI) to set up a connection that can withstand more than 30 thousand concurrent connections, the following section is better than Apache's 10-fold Web server article (Load Balancing only, without the need to support PHP installation ):

II. install PHP 5.2.4 (FastCGI mode)
4. create www users and groups and their directories:

3. install Nginx 0.5.31
1. install the pcre library required by Nginx:
2. install Nginx
3. create an Nginx log Directory
5. start Nginx

Note: this article

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.