nginx配置如下:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 定义负载均衡服务器列表
upstream svr_balance{
ip_hash; #均衡规则为 根据客户端ip地址的哈希值来分配
server 192.168.78.177;
server 202.202.202.167;
}
server {
# 虚拟服务器 http://192.168.78.177:8081
listen 8081;
server_name localhost;
location / {
root /usr/local/nginx/html/; #网站根目录
index index.php index.html index.htm; #定义首页索引文件的名称
}
# 定义 http://192.168.78.177:8081/AlienWi/ 访问规则
location /AlienWi/{
proxy_pass http://svr_balance/AlienWi/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
不同的客户端(ip地址同一网段,不同网段都有测试)访问http://192.168.78.178:8081/AlienWi/ 为什么总是访问到202.202.202.167, 而没有访问到192.168.78.177呢