mirror of https://github.com/Qortal/Brooklyn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1011 B
35 lines
1011 B
set $authorization ''; |
|
|
|
set_by_lua $proxyuri ' |
|
unescaped = ngx.unescape_uri(ngx.var.arg_uri); |
|
it, err = ngx.re.match(unescaped, "(https?://)(.*@)?([^/]*)(/.*)?"); |
|
if not it then |
|
-- Hack to cause nginx to return 404 |
|
return "http://localhost/404" |
|
end |
|
|
|
scheme = it[1]; |
|
authstring = it[2]; |
|
host = it[3]; |
|
query = it[4]; |
|
|
|
if authstring then |
|
auth = string.sub(authstring, 0, -2); |
|
auth64 = ngx.encode_base64(auth); |
|
ngx.var.authorization = "Basic " .. auth64; |
|
end |
|
|
|
-- Default to / if none is set to avoid using the request_uri query |
|
if not query then |
|
query = "/"; |
|
end |
|
|
|
return scheme .. host .. query; |
|
'; |
|
|
|
add_header X-GG-Cache-Status $upstream_cache_status; |
|
proxy_set_header Authorization $authorization; |
|
|
|
proxy_pass $proxyuri; |
|
# Redirect back to ourselves on 301 replies |
|
proxy_redirect ~^(.*)$ /cache/?uri=$1;
|
|
|