无效/丢失主机名的 Http 响应代码

标签 http dns

假设我有 ip 1.2.3.4 并将其映射到以下名称

folk.dude.cool
homie.dude.cool
bro.dude.cool
pal.dude.cool
buddy.dude.cool

我检查我的 http 服务器中的 Host header 值以将请求转发到相关模块。

现在当 Host header 的值丢失或者无效的?我注意到我喜欢显示错误页面而不是转发到默认名称。

谢谢。

最佳答案

朱利安是正确的:

RFC 2616 - 14.23 Host

... A client MUST include a Host header field in all HTTP/1.1 request messages . If the requested URI does not include an Internet host name for the service being requested, then the Host header field MUST be given with an empty value. An HTTP/1.1 proxy MUST ensure that any request message it forwards does contain an appropriate Host header field that identifies the service being requested by the proxy. All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request) status code to any HTTP/1.1 request message which lacks a Host header field.

当您遇到协议(protocol)问题时,RFC 读起来有点枯燥,但信息量很大。

关于无效/丢失主机名的 Http 响应代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30356283/

相关文章:

php - cloudflare 的 SSL 错误

amazon-web-services - Route 53 Amazon DNS 查找失败

java - 如何处理 $_REQUEST 中可变数量的数据?

Python Web自动化: HTTP Requests OR Headless browser

http - Golang 'http.NewRequest(method, url, body)' 无法创建正确格式的请求

wordpress - 使用 CloudFormation 创建 Wordpress 博客,但域未正确显示

dns - 如何 "Mask"具有真实域名的子域名?

email - 有没有人用 CakePHP 电子邮件组件设置 DKIM?

c# - 从 HttpMethod POST 切换到 Get 时 ASPX 丢失 session

http - 什么是有效的 RFC1123 日期格式