Elastic Load Balancer在Beanstalk应用中未通过X

编程入门 行业动态 更新时间:2024-10-28 13:24:17
本文介绍了Elastic Load Balancer在Beanstalk应用中未通过X-Forwarded-For的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前正在测试将Webapp部署到Elastic Beanstalk实例上的情况.我创建了一个准系统应用程序,该应用程序使用jstl标签简单地输出请求标头,还可以从控制器内部获取标头.

I am currently testing the deployment of our webapps onto an Elastic Beanstalk instance. I have created a barebones app that simply outputs the request headers using jstl tags, and also by grabbing the header from inside a controller.

但是,看来负载均衡器没有添加/发送X-Forwarded-For参数,所以我找不到原始IP.我收到的标头参数如下:-

However, it seems the load balancer is not adding/sending the X-Forwarded-For parameter, so I cannot find the origin IP. The header params I receive are as follows:-

cookie: AWSELB=09D969F91EF3C3604AB87D64987C7C54D857FED9A34F717D91F616079AC29E2AD67BDF984862A60ACA38A4EB6D54DC6257C08DB00AC6FE1F7F528DAC6C84D40EF4FCBC81AB cache-control: no-cache connection: Keep-Alive accept-language: en-US,en;q=0.5 host: barebones-env.elasticbeanstalk x-forwarded-port: 80 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 x-forwarded-host: barebones-env.elasticbeanstalk user-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0 accept-encoding: gzip, deflate x-forwarded-server: ip-10-58-127-10.eu-west-1pute.internal x-forwarded-proto: http pragma: no-cache IP Address from Controller = //this is blank, it should be getting servletRequest.getHeader("X-FORWARDED-FOR");

创建新的Elastic beantalk环境后,我没有更改任何设置.有人有什么主意吗?

I have not changed any settings after creating a new elastic beanstalk environment. Does anybody have any ideas?

谢谢,达米安

推荐答案

的确,负载均衡器通常会将具有自己IP地址的请求转发到其背后的服务器,并以 X-Forwarded-For 标头.但是,Elastic Load Balancer似乎比这更透明.我不知道您使用的是哪种编程语言,但是在Java/Spring环境中,通过在 HttpServletRequest 上调用 getRemoteAddr()可以很好地解决问题.换句话说,我认为您根本不需要理会 X-Forwarded-For 标头.

It is true that a load balancer will typically forward requests with its own IP address to the servers behind it, and the client's IP in an X-Forwarded-For header. However, the Elastic Load Balancer seems a bit more transparent than that. I don't know what programming language you're using, but in my Java/Spring environment I get by just fine with a call to getRemoteAddr() on my HttpServletRequest. In other words, I don't think you need to bother with the X-Forwarded-For header at all.

祝你好运!

更多推荐

Elastic Load Balancer在Beanstalk应用中未通过X

本文发布于:2023-11-15 07:52:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1592545.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中未   Load   Elastic   Beanstalk   Balancer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!