大于6点小于 24点时禁止Google 抓取网站内容
location / {
access_by_lua_block {
local date = os.date("*t")
local hour = date.hour
local ua = ngx.var.http_user_agent
local is_googlebot = ua and (string.match(ua, "Googlebot") or string.match(ua, "Mediapartners-Google")) ~= nil
if is_googlebot then
if hour >= 6 and hour < 24 then
ngx.status = 403
ngx.say("Googlebot is only allowed between 00:00 and 06:00.")
ngx.exit(403)
end
end
}
# 正常内容
root /usr/share/nginx/html;
index index.html;
}
原创文章,作者:admin,如若转载,请注明出处:https://cuue.cn/598.html