# 链接到自有域名导致“内部服务器错误”

**URL:** <https://meta.discourse.org/t/link-to-own-domain-results-in-internal-server-error/125332>\
**Category:** Support\
**Created:** [2019年八月9日 15:04 UTC](https://meta.discourse.org/t/link-to-own-domain-results-in-internal-server-error/125332 "2019-08-09T15:04:38Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![klopsknoedel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klopsknoedel/32/194126_2.png) [@klopsknoedel](https://meta.discourse.org/u/klopsknoedel)\
**Post date:** [2019年九月18日 08:43 UTC](https://meta.discourse.org/t/link-to-own-domain-results-in-internal-server-error/125332/6 "2019-09-18T08:43:23Z")

</div>

您好，

为了完成此事，我们发现在已应用的补丁中存在一个错误。我们遇到了与 [此主题](https://meta.discourse.org/t/invalid-input-for-update-ip-address/77085) 中描述相同的问题，因为我们使用的是 Azure Application Gateway V1。  
[在此帖子](https://meta.discourse.org/t/invalid-input-for-update-ip-address/77085/17?u=klopsknoedel) 中，我描述了为规避该问题所采取的措施。

不过，似乎当创建指向您自己主机名的链接时，`request.ip` 为 `nil`，导致我们的变通方案失效。我们通过将其包裹在 `begin…rescue…end` 块中解决了该问题，如下所示：

```ruby
begin
  ip_port_split = request.ip.split(':')
  ip_only = ip_port_split.first
rescue
  ip_only = request.ip
end

```

我们期待下一个 `rack` 更新/发布，因为它应该/将会正确处理这些 `x-forwarded-for` 头。

感谢您的时间，此致  
Sascha

---

_[View the full topic](https://meta.discourse.org/t/link-to-own-domain-results-in-internal-server-error/125332)._
