nginx~对没有定义service_name的三级域名进行过滤
在nginx配置过程中,你可能遇到过三级域名(泛域名)的问题,当你没有定义它时,它会使用顶级域名的路由,你可以在配置中进行过滤.
server {
listen 80;
server_name lind.company.cn *.lind.company.cn;
#匹配没有定义过servicename的三级域名,让它去404
if ($host ~* ^(.+)\.([^\.]+)\.([^\.]+)\.([^\.]+)$)
{
return 404;
}
location / {
root /home/web;
index index.html;
}
server {
listen 80;
server_name abc.lind.company.cn;
}
经过上面的配置之后,当你输入abc.lind.company.cn它可以正常解析,而当你输入xyz.lind.company.cn时,它将返回到404页面。
原文链接:https://www.cnblogs.com/lori/p/12704611.html
如有疑问请与原作者联系
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有