在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.uj5u.com/caozuo/103618.html
標籤:Linux
上一篇:Linux編程實作遞回查找檔案
