简体   繁体   English

在登台服务器中有效的URL无效,但在生产中失败

[英]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.110.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.

相关问题 大长查询字符串在登台服务器上工作正常,在生产服务器上返回 HTTP 406? - Big long query string works fine on staging server, returns HTTP 406 on production server? 条件在本机生产中反应失败,但在开发中有效 - Condition fails in react native production, but works in development 反应助手导入在生产中失败,但在开发中工作 - react helper import fails in production but works in development Firebase 在本地主机上登录失败,但在生产中工作 - Firebase Login Fails on Localhost but works in Production fs.writeFile 适用于 localhost 但不适用于生产服务器 - fs.writeFile works on localhost but not production server 用于制作和登台的不同样式表 - Different style sheets for production and staging ASP.NET MVC Bundle 未在登台服务器上呈现脚本文件。 它适用于开发服务器 - ASP.NET MVC Bundle not rendering script files on staging server. It works on development server axios.post在应用程序中失败,在URL中工作 - axios.post Fails in App, Works in URL Laravel Ajax URL在生产服务器上不起作用 - Laravel ajax url not working on production server JavaScript函数拒绝在生产服务器上运行,但在本地服务器上运行 - JavaScript function refuses to work on production server but works on local server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM