代理背后的 Express
在反向代理后面运行 Express 应用程序时,某些 Express API 可能返回与预期不同的值。为了对此进行调整,trust proxy
应用程序设置可用于公开由 Express API 中的反向代理提供的信息。最常见的问题是公开客户端 IP 地址的快速 API 可能会显示反向代理的内部 IP 地址。
配置
trust proxy
设置时,了解反向代理的确切设置非常重要。由于此设置将信任请求中提供的值,因此 Express 中的设置组合与反向代理的操作方式相匹配非常重要。
应用程序设置 trust proxy
可以设置为下表中列出的值之一。
类型 | 值 |
---|---|
布尔值 | 如果是 VmqBX2CbLR/lHY5vCjpWLUt8APxu/FNKhziyTNeo9gtDckQMggp3Gx+LQnrnCXaLbC+dWL00Uln47U3Rr4Q9EC9TPVfblAE3ecuejBLiyk2seisNiZI0qSagTDKcjIcPzLObSoV9KlzLPX/fHIXiIPsm/jfzLim37dNbCyBHaT0hkOSCoKiAE9rFyf/1+f9pCdwoj72pun2prrLc4b++JFfPIB7msFVy2ukA5zdz/+c=
|
Hswnw+eJ0MXbqy6HqeJ3bg== | uIA75P8FpyHvd8B6o1uDVl0SA3jLIuO8WUcJ3u/CrNtibC+mp3Ua1JceaK+Kt1zRYDNN5dDIEZ0Dz1REmVzqOK5hkaBiPKuCr1j8d5HQxKpypxoUXIak/fY3VxR8R9CK2HF7pJ+KjE70PTISfeTXKKcoUPWWQAkm1LpH5E7N3jXo7AVndLpfRPzUyN63MBFl
dCJrVLICKUtOZiyvhjU6EyZl2LMrjZ8r4WzJ4plMpUo3wVxUOkA/PZ/5Ky5uFqtxtl2hRKfH6ZumlemBjn/J9Q==
h5HTfO9lDYM5mCMGuhhVIGnz6yBGRnelXjCwRmFEuWkRRnLKF7XrhBAJHFFlaUGVM8exz7ugFU/uWF+Xd4pquILFsu0WVm1ple5/wCkdW1cVxCTiDPmTfzympY3KoLql/3YXq1n4vlNiD+kiZ81J8tUTO/Vy9DqRTJhO7VQxr1z862t4BqsBMZm1VsIOKSan2I5Yn5VtbHBT8llBco3gWr9D1R57Xn7HPlGOHfbEMCuQzn3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