看看
Nginx
官方文件
here
.
我认为你误解了负载平衡的概念。
我假设你有4个VPS
Nginx
安装在每一个。其中一个用于负载平衡,另外三个用于提供文件。
你的期末考试
Nginx
配置文件可能如下所示:
负载平衡器
http {
upstream myapp {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://myapp;
}
}
}
内容服务器1
http {
server {
server_name srv1.example.com;
listen 80;
location / {
try_files $uri =404;
}
}
}
内容服务器2
http {
server {
server_name srv2.example.com;
listen 80;
location / {
try_files $uri =404;
}
}
}
内容服务器3
http {
server {
server_name srv3.example.com;
listen 80;
location / {
try_files $uri =404;
}
}
}