Welcome! Log In Create A New Profile

Advanced

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

Jelle de Jong
January 24, 2022 05:02AM
Thank you for taking a look!

On 1/24/22 00:45, Francis Daly wrote:
> On Fri, Jan 21, 2022 at 12:45:16PM +0100, Jelle de Jong wrote:
>
> Hi there,
>
>> 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).
>
> For what I think you are asking for, I think the answer is a combination
> of "stock nginx does not let you cache at that level"; and "it should
> not matter; that lookup should be lightweight".
>
> But I'm not quite sure what you are asking for; or why you are asking
> for it. So maybe there's a different answer too.

I want to be able to do an redirect, but only one time, the hit it
should not redirect.

If a client visits an web-store it will get redirected to the region
specific store, but if then then manually select an other store there it
should not redirect back again. I don't know if a nginx session cookie
is possible or an way to use the nginx upstream module?

I am open to ideas to make this work.

Kind regards,

Jelle de Jong
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

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

Jelle de Jong January 21, 2022 06:50AM

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

Francis Daly January 23, 2022 06:50PM

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

Jelle de Jong January 24, 2022 05:02AM

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

Reinis Rozitis January 24, 2022 05:20AM

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

Jelle de Jong January 24, 2022 10:14AM

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

Reinis Rozitis January 24, 2022 12:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 105
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready