Implementing the Environment:
VMware Workstation 11
Under the centos6.7 system
Nginx Server: 192.168.239.136 firewall off Setenforce 0
Apache Server 1:192.168.239.138 firewall off Setenforce 0
Apache server 2:192.168.239.139 Firewall off Setenforce 0
SECURECRT (SSH remote connection software)
Software Introduction:
Nginx Introduction
Nginx is a very lightweight HTTP server written by a Russian .
L High-performance HTTP and reverse proxy server, also proxy IMAP/POP3/SMTP server
Nginx has been known for its stability, rich feature set, sample profile, and low system resource consumption since Nginx was released .
l Nginx is specially developed for performance optimization, and performance is the most important consideration, the implementation of which is very focused on efficiency.
L can withstand the test of high load, there are reports that can support up to 50,000 concurrent connections.
l Nginx has high stability, other HTTP servers when encountering spikes in access, or if someone maliciously initiates a slow connection, it is also likely to cause the server to run out of physical memory for frequent exchanges, and the loss of response can only restart the server.
L Low Cost
buy F5 big-IP netscaler hardware load balancer switch Hundreds of thousands of
Nginx based on BSD Open source protocol free, commercially available
l support rewrite rewrite rules
ability to distribute HTTP requests to different back-end server groups based on domain names and URL differences
l built-in health check function
if a Web server on the backend of Nginx proxy goes down, it will not affect the front-end access
Bandwidth Savings
L Support gzip compression
Header for browsing local cache can be added
L High Stability
use reverse proxies, virtually no downtime
• Support for hot deployment
continuous service for updates
Test Flow:
First, Software Installation
[email protected] ~]# Yum install-y nginx
Note: CentOS's official Yum source does not contain nginx, so we want to use Yum to configure the Epel source
You can refer to the following links
Http://www.centoscn.com/CentOS/config/2014/0920/3793.html
Second, Nginx load balancer configuration file modification.
Just change it to my bottom.
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;
#增加的
Upstream Web1 {
Server 192.168.239.139:80 weight=1 max_fails=2 fail_timeout=30s;
Server 192.168.239.138:80 weight=1 max_fails=2 fail_timeout=30s;
}
#增加的
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; #这里需要注释掉, or it won't work.
}
Third, restart Nginx
[Email protected] ~]#/usr/sbin/nginx-s Reload
Iv. Add a test page above the apache1.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/82/29/wKioL1dNPg-gBf9GAAD2sGHTqSU535.png-wh_500x0-wm_3 -wmp_4-s_3481721318.png "title=" 001.png "alt=" Wkiol1dnpg-gbf9gaad2sghtqsu535.png-wh_50 "/>
V. Add a test page above the Apache2
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/82/29/wKioL1dNPlLQVhzRAADLZx9GaE8189.png-wh_500x0-wm_3 -wmp_4-s_2948794752.png "title=" 002.png "alt=" Wkiol1dnpllqvhzraadlzx9gae8189.png-wh_50 "/>
Six, test on my physical machine!
Enter the Nginx IP in the browser
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/82/2B/wKiom1dNPibyllGTAAAzjlKuhqs824.png-wh_500x0-wm_3 -wmp_4-s_1075579482.png "style=" Float:none; "title=" 003.png "alt=" Wkiom1dnpibyllgtaaazjlkuhqs824.png-wh_50 "/>
Refresh
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/82/2B/wKiom1dNPibxch9kAAA-7Dxh8XU761.png-wh_500x0-wm_3 -wmp_4-s_3768309171.png "style=" Float:none; "title=" 004.png "alt=" Wkiom1dnpibxch9kaaa-7dxh8xu761.png-wh_50 "/>
Thank you
This article from "A few" blog, declined reprint!
centos6.7 using Nginx for load Balancing!