http-cookies-filter #
A NGINX module for fine-grained request cookies control.
Source: upstream source
Directives
Example
http {
server {
listen 80;
server_name example.com;
location / {
# If a cookie named "a" exists, set it to 1. Otherwise, add a cookie named "a" with value 1.
set_request_cookie a 1;
# If a cookie named "b" exists, do nothing. Otherwise, add a cookie named "a" with value 1.
add_request_cookie b 2;
# If a cookie named "c" exists, set it to 3. Otherwise, do nothing.
modify_request_cookie c 3;
# If a cookie named "d" exists, delete it. Otherwise, do nothing.
clear_request_cookie d;
# Conditional filtering. Only effected if varialbe $http_a is not empty or '0'.
set_request_cookie e 4 if=$http_a;
# Send the filtered cookies to upstream.
proxy_set_header Cookie $filtered_request_cookies;
proxy_pass http://127.0.0.1:8080;
}
}
}