nginx配置文件位置:
/usr/local/nginx/conf/nginx.conf
我们可以在nginx进行配置(可以放在http内)
http{
proxy_set_header X-Forwarded-For $remote_addr;
}
保存,重新加载nginx
nginx -s reload
// 获取真实IP
public static String getIpAddress(HttpServletRequest request) {
// nginx 配置的ip header
String ip = request.getHeader("X-Forward-For");
}