![](https://csdnimg.cn/release/download_crawler_static/86317353/bg4.jpg)
2018/4/14 Nginx的反向代理与负载均衡 - 惨绿少年
https://www.nmtui.com/clsn/lx429.html 4/18
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 80;
server_name bbs.etiantian.org;
location / {
root html/bbs;
index index.html index.htm;
}
access_log logs/access_bbs.log main;
}
server {
listen 80;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
}
1.3.5 统一nginx测试环境 (web文件)
mkdir -p /application/nginx/html/{www,bbs}
for name in www bbs; do echo $name `hostname` >/application/nginx/html/$name/xiaoxinxin.html;done
for name in www bbs; do cat /application/nginx/html/$name/xiaoxinxin.html;done
1.3.6 测试
[root@lb01 ~]# curl -H host:bbs.etiantian.org 10.0.0.8/xiaoxinxin.html
bbs web01
[root@lb01 ~]# curl -H host:bbs.etiantian.org 10.0.0.7/xiaoxinxin.html
bbs web02
[root@lb01 ~]# curl -H host:bbs.etiantian.org 10.0.0.9/xiaoxinxin.html
bbs web03
[root@lb01 ~]# curl -H host:www.etiantian.org 10.0.0.8/xiaoxinxin.html
www web01
[root@lb01 ~]# curl -H host:www.etiantian.org 10.0.0.7/xiaoxinxin.html
www web02
[root@lb01 ~]# curl -H host:www.etiantian.org 10.0.0.9/xiaoxinxin.html
www web03
1.3.7 配置负载服务文件
worker_processes 1;
events {