jackyrar 发表于 2019-1-2 10:38:27

haproxy后端nginx取得用户访问ip地址

set_real_ip_from 172.16.100.120;#haproxy 的IP地址
      set_real_ip_from 172.16.100.110;#haproxy 的IP地址
      real_ip_header X-Forwarded-For;
      log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';  haproxy 里http下 option forwardfor
  nginx配置文件设置如上

  后端nginx服务可以取得用户访问的真实ip地址。




页: [1]
查看完整版本: haproxy后端nginx取得用户访问ip地址