Use nginx on centos6.7 for Load Balancing
Implementation environment:
Vmware workstation 11
Under centos6.7
Nginx server: 192.168.239.136 firewall disable setenforce 0
Apache Server 1: Firewall 192.168.239.138 disable setenforce 0
Apache server 2: Firewall 192.168.239.139 disable setenforce 0
SecureCRT (ssh remote connection software)
Software introduction:
Nginx Introduction
LNginx is a lightweight HTTP server written by Russians.
L high-performance HTTP and reverse proxy servers, as well as IMAP/POP3/SMTP servers
Since the release of lNginx, Nginx has become famous for its stability, rich feature sets, sample configuration files, and low system resource consumption.
LNginx is designed for performance optimization. performance is the most important consideration, and efficiency is very important in implementation.
L able to withstand the high load test. The report shows that it can support up to 50,000 concurrent connections.
LNginx has high stability. When other HTTP servers encounter access peaks or maliciously initiate slow connections, it is also likely that the server's physical memory is exhausted and frequently exchanged, the server can only be restarted if the response is lost.
L Low Cost
Buy F5Big-IPNetScaler hardware Load balancer vswitches several 100,000
Nginx is free and commercially available based on BSD open source Protocol
L supports rewrite Rules
Distribute HTTP requests to different backend server groups based on different domain names and URLs.
L built-in health check functions
If a Web server at the back end of NginxProxy goes down, front-end access will not be affected.
Save bandwidth
L supports GZIP Compression
You can add headers to browse the local cache.
L High Stability
Reverse Proxy, almost no downtime
L support hot deployment
Constantly Update Services
Test process:
I. Software Installation
[Root @ localhost ~] # Yum install-y nginx
Note: The official yum source of centos does not contain nginx, so if we want to use yum, We need to configure the epel source.
You can refer to the following link
Http://www.centoscn.com/CentOS/config/2014/0920/3793.html
2. Modify the nginx Server Load balancer configuration file.
You just need to change this to the one below me.
Http {
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';
Access_log/var/log/nginx/access. log main;
Sendfile on;
# Tcp_nopush on;
# Keepalive_timeout 0;
Keepalive_timeout 65;
# Added
Upstream web1 {
Server 192.168.239.139: 80 weight = 1 max_fails = 2 fail_timeout = 30 s;
Server 192.168.239.138: 80 weight = 1 max_fails = 2 fail_timeout = 30 s;
}
# Added
Server {
Listen 80;
Server_name localhost;
Location /{
Proxy_pass http: // web1;
Root html;
Index index.html index.htm;
}
}
# Gzip on;
# Load config files from the/etc/nginx/conf. d directory
# The default server is in conf. d/default. conf
# Include/etc/nginx/conf. d/*. conf; # comment out here, otherwise it will not work.
}
3. Restart nginx
[Root @ localhost ~] #/Usr/sbin/nginx-s reload
4. Add a test page on apache1.
5. Add a test page on apache2.
6. Test on my physical machine!
Enter the nginx ip address in the browser
Refresh