# 反向代理 X-Forwarded-For

**URL:** <https://meta.discourse.org/t/reverse-proxy-x-forwarded-for/403181>\
**Category:** Support\
**Tags:** unsupported-install, nginx\
**Created:** [2026年五月17日 04:27 UTC](https://meta.discourse.org/t/reverse-proxy-x-forwarded-for/403181 "2026-05-17T04:27:01Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Eviepayne](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviepayne/32/352733_2.png) [@Eviepayne](https://meta.discourse.org/u/Eviepayne)\
**Post date:** [2026年五月17日 05:56 UTC](https://meta.discourse.org/t/reverse-proxy-x-forwarded-for/403181/5 "2026-05-17T05:56:18Z")

</div>

> [@Eviepayne](#):
>
> `set_real_ip_from loadbalancerip;`

需要这一行才能正常工作。  
如果没有它，所有请求的 IP 仍然是负载均衡器的 IP。  
我之所以知道，是因为我的 Discourse 因为 429 错误而宕机了。

如果还不清楚，这是我的基础设施架构：  
用户 \> haproxy \> discourse

当然，Discourse 内部包含一个 nginx 反向代理。

我已在 haproxy 中包含了转发头，但 Discourse 内部的 nginx 并未尊重 `X-Forwarded-For` 头。我不得不在我的原始帖子中添加这两行，并重启容器，问题才得以解决。

---

_[View the full topic](https://meta.discourse.org/t/reverse-proxy-x-forwarded-for/403181)._
