Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
Created April 12, 2020 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leandromoreira/11b4b3cf5f41c5a96d2b981b24c610c3 to your computer and use it in GitHub Desktop.
Save leandromoreira/11b4b3cf5f41c5a96d2b981b24c610c3 to your computer and use it in GitHub Desktop.
server {
location / {
proxy_cache my_cache;
proxy_cache_lock on;
proxy_pass http://backend;
access_by_lua_block {
local token = ngx.var.arg_token or ngx.var.cookie_superstition
if token ~= "token" then
return ngx.exit(ngx.HTTP_FORBIDDEN)
else
ngx.header['Set-Cookie'] = {'superstition=token'}
end
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment