Last active
December 29, 2015 23:49
-
-
Save leafo/7745145 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
worker_processes 1; | |
error_log stderr notice; | |
daemon off; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
server { | |
listen 8181; | |
default_type text/html; | |
location /proxy { | |
internal; | |
rewrite_by_lua " | |
local req = ngx.req | |
print(ngx.var._url) | |
for k,v in pairs(req.get_headers()) do | |
if k ~= 'content-length' then | |
req.clear_header(k) | |
end | |
end | |
if ngx.ctx.headers then | |
for k,v in pairs(ngx.ctx.headers) do | |
req.set_header(k, v) | |
end | |
end | |
"; | |
resolver 8.8.8.8; | |
proxy_http_version 1.1; | |
proxy_pass $_url; | |
} | |
# ../ngx_lua-0.9.2/src/ngx_http_lua_headers_in.c:706: ngx_http_lua_rm_header_helper: Assertion `cur->next != ((void *)0)' failed. | |
# 2013/12/01 20:34:21 [notice] 1903#0: signal 17 (SIGCHLD) received | |
# 2013/12/01 20:34:21 [alert] 1903#0: worker process 1926 exited on signal 6 (core dumped) | |
# 2013/12/01 20:34:21 [notice] 1903#0: start worker process 1992 | |
location /first { | |
set $_url ""; | |
content_by_lua ' | |
local res = ngx.location.capture("/proxy", { | |
ctx = { | |
headers = { | |
["Content-type"] = "application/x-www-form-urlencoded" | |
} | |
}, | |
vars = { _url = "http://leafo.net" } | |
}) | |
local res = ngx.location.capture("/proxy", { | |
ctx = { | |
headers = { | |
["x-some-date"] = "Sun, 01 Dec 2013 11:47:41 GMT", | |
["x-hello-world-header"] = "123412341234", | |
["Authorization"] = "Hello" | |
} | |
}, | |
vars = { _url = "http://leafo.net" } | |
}) | |
'; | |
} | |
# ../ngx_lua-0.9.2/src/ngx_http_lua_headers_in.c:176: ngx_http_set_header_helper: Assertion `!(r->headers_in.headers.part.next == ((void *)0) && r->headers_in.headers.last != &r->headers_in.headers.part)' failed. | |
# 2013/12/01 20:33:34 [notice] 1903#0: signal 17 (SIGCHLD) received | |
# 2013/12/01 20:33:34 [alert] 1903#0: worker process 1911 exited on signal 6 (core dumped) | |
# 2013/12/01 20:33:34 [notice] 1903#0: start worker process 1926 | |
location /second { | |
set $_url ""; | |
content_by_lua ' | |
local res = ngx.location.capture("/proxy", { | |
method = ngx.HTTP_POST, | |
body = ("x"):rep(600), | |
ctx = { | |
headers = { | |
["Content-type"] = "application/x-www-form-urlencoded" | |
} | |
}, | |
vars = { _url = "http://leafo.net" } | |
}) | |
local res = ngx.location.capture("/proxy", { | |
ctx = { | |
headers = { | |
["x-some-date"] = "Sun, 01 Dec 2013 11:47:41 GMT", | |
["x-hello-world-header"] = "123412341234", | |
["Authorization"] = "Hello" | |
} | |
}, | |
vars = { _url = "http://leafo.net" } | |
}) | |
local res = ngx.location.capture("/proxy", { | |
vars = { _url = "http://leafo.net" } | |
}) | |
'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment