Created
May 29, 2014 07:30
-
-
Save leafo/c37b164a5da47715fe28 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
error_log stderr notice; | |
daemon off; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
variables_hash_max_size 1024; | |
server { | |
listen ${{PORT}}; | |
lua_code_cache ${{CODE_CACHE}}; | |
location / { | |
default_type text/html; | |
set $_url ''; | |
content_by_lua_file "web.lua"; | |
} | |
location /proxy { | |
internal; | |
rewrite_by_lua " | |
local req = ngx.req | |
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; | |
} | |
location /static/ { | |
alias static/; | |
} | |
location /favicon.ico { | |
alias static/favicon.ico; | |
} | |
} | |
} |
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
local lapis = require "lapis" | |
local app = lapis.Application() | |
local http = require "lapis.nginx.http" | |
app:get("/", function(self) | |
return self:html(function() | |
pre(require("moon").dump({ | |
http.request("http://www.google.com") | |
})) | |
end) | |
end) | |
lapis.serve(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment