Last active
August 29, 2015 14:03
-
-
Save leafo/4d171e76a32e9b471bba 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
local lapis = require "lapis" | |
local app = lapis.Application() | |
app:get("/", function() | |
local http = require "lapis.nginx.http" | |
local util = require "lapis.util" | |
local api = "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?" | |
local res, status = http.simple(api .. util.encode_query_string { | |
url = "http://leafo.net", | |
key = "xxx", | |
filter_third_party_resources = "true", | |
screenshot = "true", | |
strategy = "desktop" | |
}) | |
return res | |
end) | |
lapis.serve(app) |
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 ${{NUM_WORKERS}}; | |
error_log stderr notice; | |
daemon off; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
server { | |
listen ${{PORT}}; | |
lua_code_cache ${{CODE_CACHE}}; | |
location / { | |
set $_url ""; | |
default_type text/html; | |
content_by_lua_file "app.lua"; | |
} | |
location /static/ { | |
alias static/; | |
} | |
location /favicon.ico { | |
alias static/favicon.ico; | |
} | |
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment