[英]Invalid URL that works in staging server but fails in production
I just spent a whole night figuring out why our production server had a bug that was missed in our staging servers. 我花了一整夜的时间弄清楚为什么我们的生产服务器存在一个登台服务器中漏掉的错误。 And this morning, I finally narrowed it down and nailed it to this piece of code: 今天早上,我终于将其范围缩小并固定到以下代码段:
url = [ database.protocol, '//' + database.host, database.port, ].join(':');
url = [ url, database.db ].join('/');
Yeah. 是的 How on earth could this actually work? 这到底如何工作? Well, in staging it showed: 好吧,分期显示:
http://:localhost:5984/fo
But in master it showed 但是在主人看来
http://:10.x.x.x:5984/fo (x is a number)
The former worked, but the latter didn't. 前者有效,而后者却无效。 This is where my knowledge on URLs fail me. 这是我对URL的了解使我失望的地方。 How on earth is the former valid but the latter not? 究竟前者有效,而后者无效吗?
EDIT: 编辑:
To be clear, I think both URLs should be invalid, that this is a bug that should be caught in my staging server. 需要明确的是,我认为两个URL都应该无效,这是应该在我的登台服务器中捕获的错误。 I just want to know why the former URL (:localhost) is interpreted as valid but the latter isn't. 我只想知道为什么前一个URL(:localhost)被解释为有效,而后者却无效。
localhost
is (almost always) 127.0.0.1
. localhost
(几乎总是) 127.0.0.1
。 127.0.0.1
is very different to 10.xxx
. 127.0.0.1
与10.xxx
非常不同。
If the server is listening on localhost
, only connections coming from the server itself will be received. 如果服务器在localhost
上侦听,则只会接收来自服务器本身的连接。 Therefore even entering the server's IP is not enough to connect to it from the outside. 因此,即使输入服务器的IP也不足以从外部连接到它。
Make sure the server is listening on its network IP, rather than the loopback. 确保服务器正在侦听其网络IP,而不是环回。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.