Skip to content

Instantly share code, notes, and snippets.

@camathieu
Created July 5, 2015 20:42
Show Gist options
  • Save camathieu/d9a47cf018441f2752be to your computer and use it in GitHub Desktop.
Save camathieu/d9a47cf018441f2752be to your computer and use it in GitHub Desktop.
plik nginx configuration
upstream plik {
server 127.0.0.1:8080;
server 127.0.0.1:8081;
}
upstream stream {
server 127.0.0.1:8080;
server 127.0.0.1:8081;
hash $key;
}
server {
listen 9000;
location / {
set $upstream "";
set $key "";
access_by_lua '
_,_,key = string.find(ngx.var.request_uri, "^/stream/[a-zA-Z0-9]{16}/([a-zA-Z0-9]{16})/.*$")
if key == nil then
ngx.log(ngx.STDERR, "regular upload")
ngx.var.upstream = "plik"
else
ngx.log(ngx.STDERR, "stream upload")
ngx.var.upstream = "stream"
ngx.var.key = key
end
';
proxy_pass http://$upstream;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment