Skip to content

Instantly share code, notes, and snippets.

@amgorb
Created November 11, 2016 12:56
Show Gist options
  • Save amgorb/ce0e6c588fcccd176acebce177a255f5 to your computer and use it in GitHub Desktop.
Save amgorb/ce0e6c588fcccd176acebce177a255f5 to your computer and use it in GitHub Desktop.
I have Lua script that manipulates cookies and headers based at GET parameters.
This script didnt work well at one location, strangely the ngx.var.args was empty with ordinary request.
The trick was that in location we have:
location /x/ {
header_filter_by_lua_file /etc/nginx/lua/referrer_cookie.lua;
rewrite ^/x/(.*) /$1 break;
try_files $uri /x/index.htm;
}
in which request went to index.html and all GETs got stripped. Solution was to add $args to the request:
location /x/ {
header_filter_by_lua_file /etc/nginx/lua/referrer_cookie.lua;
rewrite ^/x/(.*) /$1 break;
try_files $uri /x/index.htm$is_args$args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment