how to create session persistence or hash_ip within server context for an if statement

Jelle de Jong jelledejong at powercraft.nl
Fri Jan 21 11:45:16 UTC 2022


Hello everybody,

How can I use an nginx session or hash_ip in the server context to only 
do the following if statement code once and not a second time an client 
visits the website:

server {
     if ($geoip2_data_country_iso_code != GB) {
         return 302 https://test01.example.nl$request_uri;
     }
}

I want the above code to be executed only once, and then be remembered 
for the next 24 hours or so (this is flexible, not a hard requirement).

Kind regards,

Jelle de Jong



More information about the nginx mailing list