ngx_http_limit_req_module
NGINX - это HTTP-сервер и обратный прокси-сервер, почтовый прокси-сервер, а также TCP/UDP прокси-сервер общего назначения
Lua - высокоуровневый, скриптовый язык с динамической типизацией.
name = 'Yoda'
function bar(a, b)
print(a, b)
return 4, 8, 15
end
x, y = bar(name)
-- "Yoda nil nil"
-- x = 4, y = 8 server {
location /hello {
content_by_lua_block {
ngx.say('Hello,world!')
}
}
}worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}curl http://localhost:8080/
If everything is okay, we should get the output
<p>hello, world</p>server {
listen 8080;
location / {
default_type text/html;
content_by_lua_file /path/to/content.lua;
}
}uri = ngx.var.uri
ngx.say(uri)
-- try access /test?a=hello,world
ngx.say(ngx.var.arg_a)curl http://localhost:8080/test?a=hello,world
If everything is okay, we should get the output
/test
hello,worldLuaRestyMemcachedLibrary
LuaRestyMySQLLibrary
LuaRestyRedisLibrary
LuaRestyWebSocketLibrary
LuaRestyLimitTrafficLibrary
PostgresNginxModule
...
local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.say("failed to connect: ", err)
return
end
res, err = red:get("jedi")
ok, err = red:set("jedi", "Obi-Wan Kenobi")
if not ok then
ngx.say("failed to set dog: ", err)
return
end
ngx.say(res)curl http://localhost:8080/
null
curl http://localhost:8080/
Obi-Wan Kenobilocal crawlers = {}
function crawlers.user_agent_check_bot(user_agent)
-- Проверяет user_agent клиента по списку ботов на совпадение
end
function crawlers.host_check_bot(host, bot)
-- Проверяет хост клиента на совпадение со списком хостов ботов
end
function crawlers.is_bot(storage, user_agent, ip)
-- Проверяет является ли клиент поисковым ботом
endclient = {}
function client:new(id, type, rps_storage, bans_storage, path_to_banlist)
local obj = {}
function obj:check_ban()
-- проверяем бы ли забанен ip
end
function obj:add_ban(time)
-- добавить в бан
end
-- тело класса
function obj:count_success_captcha()
-- сколько каптч отгадал пользователь
end
return setmetatable(obj, self)
end https://habrahabr.ru/company/2gis/blog/199504/
http://www.highload.ru/2013/abstracts/934.html
https://www.youtube.com/watch?v=silrEB0Brvo&t=1802s