假设我有 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 的值丢失或者无效的?我注意到我喜欢显示错误页面而不是转发到默认名称。
谢谢。
最佳答案
朱利安是正确的:
... 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/