Request.UserHostAddress return IP address of Load Balancer

前端 未结 3 1547
无人及你
无人及你 2021-02-06 03:13

I have a critical line of code in my site that worked in our development environment but not on production. Well, I say it worked in development but the truth is it gave

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 03:59

    From within your own application, if nothing else has been done to help you, you're stuck. That's as much information as is available to you.

    If you're lucky, your load-balancer has been configured to add one or more extra headers with information about the original request.

    One common solution is the X-Forwarded-For header:

    The X-Forwarded-For (XFF) HTTP header field is a de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer.

    which you would then access via the Request.Headers property.

    But discovering whether this (or another) header is available is not something we can help with - you need to talk to the people who configured the load balancer for your organization.

提交回复
热议问题