-- Client options client = { -- User agent for this client user_agent = "Mozilla/5.0 (compatible; ImageFetcher/8.0; +http://images.weserv.nl/)", -- Sets the connect timeout thresold, send timeout threshold, and read timeout threshold, -- respetively, in milliseconds. timeouts = { connect = 5000, send = 5000, read = 15000, }, -- Number describing the max image size to receive (in bytes). Use 0 for no limits. max_image_size = 104857600, -- 100 MB -- Number describing the maximum number of allowed redirects. max_redirects = 10, -- Allowed mime types. Use empty table to allow all mime types allowed_mime_types = { ["image/jpeg"] = "jpg", ["image/png"] = "png", ["image/gif"] = "gif", ["image/bmp"] = "bmp", ["image/tiff"] = "tiff", ["image/webp"] = "webp", ["image/x-icon"] = "ico", ["image/vnd.microsoft.icon"] = "ico", } },
-- Throttler options throttler = { -- Redis driver redis = { scheme = "tcp", host = "127.0.0.1", port = 6379, timeout = 1000, -- 1 sec -- The max idle timeout (in ms) when the connection is in the pool max_idle_timeout = 10000, -- The maximal size of the pool for every nginx worker process pool_size = 100 }, allowed_requests = 700, -- 700 allowed requests minutes = 3, -- In 3 minutes prefix = "c", -- Cache key prefix whitelist = { ["192.168.1.77"] = true, -- Local IP ["127.0.0.1"] = true, -- Local IP ["192.168.1.168"] = true, }, policy = { ban_time = 60, -- If exceed, ban for 60 minutes cloudflare = { enabled = false, -- Is CloudFlare enabled? email = "", auth_key = "", zone_id = "", mode = "block"-- The action to apply if the IP get's banned } } } }
-- get style, eg: x-oss-process=style/preview1 local img_style = nil local uri_args = ngx.req.get_uri_args() for key, val inpairs(uri_args) do if key == "x-oss-process"andtype(val) == "string"then local i, j = string.find(val, "style/") if i and j and i == 1and j == 6then img_style = string.sub(val, 7, -1) end end end
if img_style == "preview1"then ngx.var.upstream = "192.168.1.77:18080/?url=172.17.0.2:9000" .. ngx.var.uri .. "?q=90&w=600" ngx.log(ngx.ERR, "==> upstream of <preview1>: " .. ngx.var.upstream) return ngx.exit(ngx.OK) end