最近有一个微信端要上,需要凌晨12点上线,不可能让我等到12点切流量吧,于是早早的配置好,回家睡觉
很简单,主要在nginx这层做点处理,就行了,废话不多说,直接代码
location / {
access_by_lua_block {
if ngx.time() >= 1480521600 then
local user_agent = ngx.var.http_user_agent
if user_agent ~= nil then
local m, ret = ngx.re.match(user_agent, "Android|webOS|iPhone|iPod|BlackBerry")
if m ~= nil then ngx.redirect("/app/index.html") end
end
end
}
... # 反向代理
}
改完记得 nginx -s reload
主要就是判断时间有没有超过那个点,如果超过就继续判断是否手机访问,是的话直接重定向