背景

客户通过F5提供的虚拟ip访问应用,应用通过nginx访问应用资源和转发请求
需要获取到客户的客户端真实地址

nginx安装http_realip_module模块

编译nginx时安装http_realip_module模块
./configure --prefix=/usr/local/nginx --with-http_realip_module

增加配置

修改后的配置

        location ^~ /ttt/ {
            set_real_ip_from <F5地址>;--增加
            real_ip_header X-Forwarded-For;--增加
            real_ip_recursive on;--增加
            proxy_pass http://ttt_server;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $remote_addr;
            rewrite ^/ttt/(.*)$ /ttt/$1 break;
        }

更多推荐