一臺負載均衡機器【192.168.6.47】
三臺web站點服務器【192.168.6.48】【192.168.6.49】【192.168.6.50】
具體配置如下:
負載均衡服務器【192.168.6.47】
首先安裝nginx
安裝步驟省略。。。。。
安裝正常以後,開始配置負載均衡
Vim /application/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include 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 logs/access_web.log main;
sendfile on;
keepalive_timeout 65;
upstream servers.wyf.cn {
server 192.168.6.48:80;
server 192.168.6.49:80;
server 192.168.6.50:80;
}
server {
listen 80;
server_name www.wyf.cn;
location / {
proxy_pass http://servers.wyf.cn;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
語法檢查
平滑重啓
web站點配置
首先安裝nginx
安裝步驟省略。。。。。
安裝正常以後,開始配置【三臺配置相同】
vim /application/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.wyf.cn;
location / {
root html/web;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
開始測試:
通過Windows 測試
首先配置hosts 文件
假如負載均衡服務器IP 地址192.168.6.47 www.wyf.cn