http {
#负载均衡
upstream myTest{
server 172.18.156.13:8081 weight=3;
server 172.18.156.13:8082 weight=3;
}
server {
listen 80;
server_name localhost;
access_log /usr/local/webserver/nginx/logs/80port.access.log; #访问日志
location / {
proxy_pass http://myTest; #反向代理
}
}
server {
listen 9090;
server_name localhost;
access_log /usr/local/webserver/nginx/logs/9090port.access.log; #访问日志
location / {
root html; #存放目录
index index.html index.htm; #文件名
}
}
server {
listen 9091;
server_name localhost;
access_log /usr/local/webserver/nginx/logs/9091port.access.log; #访问日志
location / {
root html; #页面存放目录
index index91.html index91.htm; #主页文件名
}
}
}
针对虚拟机的配置有三种方式:域名、ip、端口。
这里只针对端口的方式举例。