10.如何防止未定义的服务器名处理请求

官网:How nginx processes a request

翻译部分: How to prevent processing requests with undefined server names

开始!


If requests without the “Host” header field should not be allowed, a server that just drops the requests can be defined:

如果不允许请求没有host头字段 ,可以定义一个只删除请求的服务器,如下:

server {
    listen      80;
    server_name "";
    return      444;
}

Here, the server name is set to an empty string that will match requests without the “Host” header field, and a special nginx’s non-standard code 444 is returned that closes the connection.

这里,server_name被设置为"" (一个空字符串)的服务器将匹配没有带host头字段的请求,且返回一个特殊的nginx的非标准状态码444来关闭链接。


Since version 0.8.48, this is the default setting for the server name, so the  server_name "" can be omitted. In earlier versions, the machine’s  hostname was used as a default server name.

 自0.8.48版本以来,这是server_name的默认配置,所以server_name ""可以被忽略。在更早的版本中,机器的主机名被用作默认的服务器名。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值