Skip to content

Instantly share code, notes, and snippets.

@p0pr0ck5
Created September 22, 2016 20:19
Show Gist options
  • Save p0pr0ck5/74e0a558bea4f35edb712891b00e7f42 to your computer and use it in GitHub Desktop.
Save p0pr0ck5/74e0a558bea4f35edb712891b00e7f42 to your computer and use it in GitHub Desktop.
location /foo {
content_by_lua_block {
ngx.header["foo"] = "bar"
ngx.header["Set-Cookie"] = "this is a cookie"
ngx.redirect("/somewhere-else")
}
}
poprocks@soter:~/code/Lua/lua-resty-waf$ curl -D - localhost/foo
HTTP/1.1 302 Moved Temporarily
Server: openresty/1.11.2.1
Date: Thu, 22 Sep 2016 20:18:57 GMT
Content-Type: text/html
Content-Length: 167
Connection: keep-alive
foo: bar
Set-Cookie: this is a cookie
Location: /somewhere-else
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>openresty/1.11.2.1</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment