Created
September 17, 2014 09:10
-
-
Save pintsized/7b488c5c97eaa48feb33 to your computer and use it in GitHub Desktop.
proxy cookie
This file contains hidden or 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 /setcookie { | |
content_by_lua ' | |
ngx.header.set_cookie = { "login=test%2Ftest", "cookie2" } | |
ngx.say("OK") | |
'; | |
} | |
location /getcookie { | |
content_by_lua ' | |
local resty_http = require "resty.http" | |
local httpc = resty_http.new() | |
local ok, err = httpc:connect("127.0.0.1", 80) | |
local res, err = httpc:request{ | |
method = "POST", | |
headers = { | |
Host = "dev.local", | |
}, | |
path = "/setcookie", | |
} | |
local body = res:read_body() | |
for k,v in pairs(res.headers) do | |
ngx.say(k, ": ", v) | |
end | |
ngx.say(body) | |
httpc:close() | |
'; | |
} |
This file contains hidden or 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
$> curl -v -H "Host: dev.local" http://127.0.0.1/getcookie | |
Transfer-Encoding: chunked | |
Connection: keep-alive | |
Date: Wed, 17 Sep 2014 09:09:14 GMT | |
Content-Type: text/plain | |
set-cookie: login=test%2Ftest, cookie2 | |
Server: openresty/1.5.8.1 | |
OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment