Hello,
Firstable, thanks for maintaining such great modules !
What I'm trying to accomplish is the following:
1) I use Nginx as caching proxy to Apache
(using the proxy_cache directive)
- Nginx version: 1.11.8
- Lua-nginx-module: 0.10.7
2) I want Nginx to process Vary header, and be compatible with it as it does by default
(I want him to cache different content based on upstream Vary response header)
3) Sometimes I want to modify the "Vary:" header which is comming from upstream, and remove some header from it (for example User-Agent)
This I'm trying to do with lua-nginx-module (header_filter_by_lua_file)
4) My (shortened) Nginx config looks something like that:
location "/content/" {
# -----------------
# This is the actual caching config
# -------------------
# Try to manipulate vary header
# This script reads "Vary:" header, and removes "User-Agent" from it
header_filter_by_lua_file "/usr/local/nginx/lua/cache_proxy_key.lua";
proxy_cache gryzli.info_4001d4e58d3dd1fe16b6adf3339bf05a;
proxy_cache_bypass $cookie_nocache $arg_nocache $no_cache;
proxy_cache_valid 15m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass $apache_url ;
add_header X-Cache-Status $upstream_cache_status;
add_header X-Cache-Disabled v_$no_cache;
}
The problem is that proxy_cache somehow sees the original "Vary:" header (which contains User-Agent), and continues to store different cache for different user-agents.
In my "cache_proxy_key.lua" , I'm getting the Vary: header, remove User-Agent, and store it back with something like:
ngx.header.Vary = vary_header_without_user_agent ;
Do you have any suggestions, why this would not work as I expect, and maybe how can I achieve such thing ?
Thanks in advance !