为什么我的完全限定域名请求URL被Cassini Web服务器转换为IP地址请求URL?

时间:2021-12-22 20:24:03

I have a web application which depends on the browser client retaining the FQDN in order for it to work, but what is happening is that in multiple browsers I am seeing the url get converted into an ip address url (containing the correct IP address) which is getting changed by a redirect from the web server.

我有一个Web应用程序,它取决于浏览器客户端保留FQDN以使其工作,但发生的事情是在多个浏览器中我看到url被转换为ip地址url(包含正确的IP地址)正在通过Web服务器的重定向进行更改。

The web server hosting the resource is Cassini, and the HttpRequest class Url property is returning the IP address in the URL instead of the FQDN.

托管资源的Web服务器是Cassini,HttpRequest类Url属性返回URL中的IP地址而不是FQDN。

Any suggestions on how to change this behavior?

有关如何更改此行为的任何建议?

3 个解决方案

#1


This is probably a misconfiguration in your web server. In apache (for example), one can set the canonical host name to be used when doing certain rewrite procedures using the ServerName directive. One common one is when the web server adds slash to the end of your URL ("http://example.com/path" → "http://192.168.1.1/path/").

这可能是您的Web服务器中的配置错误。在apache(例如)中,可以设置在使用ServerName指令执行某些重写过程时要使用的规范主机名。一种常见的方法是当Web服务器将斜杠添加到URL的末尾时(“http://example.com/path”→“http://192.168.1.1/path/”)。

I recommend taking a peek at what's going on with curl.

我建议看看卷曲发生了什么。

#2


This is not a DNS issue, it's a web server configuration issue.

这不是DNS问题,而是Web服务器配置问题。

Yes, the DNS is used to convert the hostname part of the URL into an IP address.

是的,DNS用于将URL的主机名部分转换为IP地址。

However that IP address will never appear in the browser bar unless the web server tells it to by sending a redirect.

但是,除非Web服务器通过发送重定向告知IP地址,否则该IP地址将永远不会出现在浏览器栏中。

#3


Thanks to the helpful information provided, I was able to track down this issue to an incomplete implementation of the HttpWorkerRequest abstract class of the .NET Framework as part of the Cassini implementation. The Cassini implementation failed to override the GetServerName and the base implementation was returning the IP address instead of the domain name.

感谢所提供的有用信息,我能够将此问题追溯到作为Cassini实现的一部分的.NET Framework的HttpWorkerRequest抽象类的不完整实现。 Cassini实现无法覆盖GetServerName,并且基本实现返回的是IP地址而不是域名。

#1


This is probably a misconfiguration in your web server. In apache (for example), one can set the canonical host name to be used when doing certain rewrite procedures using the ServerName directive. One common one is when the web server adds slash to the end of your URL ("http://example.com/path" → "http://192.168.1.1/path/").

这可能是您的Web服务器中的配置错误。在apache(例如)中,可以设置在使用ServerName指令执行某些重写过程时要使用的规范主机名。一种常见的方法是当Web服务器将斜杠添加到URL的末尾时(“http://example.com/path”→“http://192.168.1.1/path/”)。

I recommend taking a peek at what's going on with curl.

我建议看看卷曲发生了什么。

#2


This is not a DNS issue, it's a web server configuration issue.

这不是DNS问题,而是Web服务器配置问题。

Yes, the DNS is used to convert the hostname part of the URL into an IP address.

是的,DNS用于将URL的主机名部分转换为IP地址。

However that IP address will never appear in the browser bar unless the web server tells it to by sending a redirect.

但是,除非Web服务器通过发送重定向告知IP地址,否则该IP地址将永远不会出现在浏览器栏中。

#3


Thanks to the helpful information provided, I was able to track down this issue to an incomplete implementation of the HttpWorkerRequest abstract class of the .NET Framework as part of the Cassini implementation. The Cassini implementation failed to override the GetServerName and the base implementation was returning the IP address instead of the domain name.

感谢所提供的有用信息,我能够将此问题追溯到作为Cassini实现的一部分的.NET Framework的HttpWorkerRequest抽象类的不完整实现。 Cassini实现无法覆盖GetServerName,并且基本实现返回的是IP地址而不是域名。