Git Product home page Git Product logo

Comments (1)

mileszhang2016 avatar mileszhang2016 commented on May 29, 2024

你提了一个非常好的问题。我尝试解答如下:

如果使用X-Forwarded-For来向下游传递Client IP,会有一些困惑。因为会有以下2种情况:
情况一: 如果请求中本来没有包含X-Forwarded-For头部
那么BFE可以添加新的头部, X-Forwarded-For: client-ip, bfe的地址

情况二:如果请求中已经包含X-Forwarded-For头部
如,X-Forwarded-For: client1, proxy1, proxy2, proxy3
那么BFE需要将自己的地址添加到末尾 X-Forwarded-For: client1, proxy1, proxy2, proxy3,BFE的地址

在第二种情况下,client的地址可能为伪造,而BFE也能将X-Forwarded-For的值如第一种情况那样做整体改写 --
因为有时还要对X-Forwarded-For的内容进行分析。如果都做了改写,则相当于把外网带来的这个信息都丢弃了。

推荐的做法是:

  1. 按照规范,在X-Forwarded-For的末尾增加BFE的地址
  2. 使用独立的头部,用于传递“BFE看到的”客户端IP地址

from bfe-book.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.