Created
September 22, 2016 20:22
-
-
Save p0pr0ck5/60137f4cff4e7d7fc1ea276feefde3fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /bar { | |
content_by_lua_block { | |
ngx.status = 301 | |
ngx.header["Set-Cookie"] = "this is a cookie" | |
ngx.header["Location"] = "/somewhere-else" | |
} | |
} | |
location /foo { | |
content_by_lua_block { | |
local res = ngx.location.capture("/bar") | |
ngx.header["Set-Cookie"] = res.header["Set-Cookie"] | |
ngx.redirect(res.header["Location"], res.status) | |
} | |
} | |
poprocks@soter:~/code/Lua/lua-resty-waf$ curl -D - localhost/foo | |
HTTP/1.1 301 Moved Permanently | |
Server: openresty/1.11.2.1 | |
Date: Thu, 22 Sep 2016 20:22:23 GMT | |
Content-Type: text/html | |
Content-Length: 191 | |
Connection: keep-alive | |
Set-Cookie: this is a cookie | |
Location: /somewhere-else | |
<html> | |
<head><title>301 Moved Permanently</title></head> | |
<body bgcolor="white"> | |
<center><h1>301 Moved Permanently</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