server {
listen 80;
server_name open.dangdang.com;
location / {
#这里需要强制执行访问的域名,否则nginx按IP分发,默认是按字母顺序加载nginx服务配置
proxy_set_header Host openb.dangdang.com;
#设置真是访客IP地址
proxy_set_header X-Real-IP $remote_addr;
#追加路由地址到X-Forwarded-For 原始IP,proxy_ip,...
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#跳转域名
proxy_pass http://openb.dangdang.com;
log_format open '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/httpd/openapi_access.log open;
}
}
#负载均衡集群
upstream openb.dangdang.com {
server 10.255.255.140:80;
server 10.255.255.142:80;
server 10.255.255.143:80;
server 10.255.255.144:80;
}