nginx跳转http请求获取真实IP地址

在location中加下面3行配置


proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;



servlet中用一下代码获取IP地址


String ip = request.getHeader("x-forwarded-for");

你可能感兴趣的:(nginx,真实IP地址)