Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx-1.20.2 NOT WORK #80

Open
cshost1 opened this issue Apr 14, 2023 · 3 comments
Open

nginx-1.20.2 NOT WORK #80

cshost1 opened this issue Apr 14, 2023 · 3 comments

Comments

@cshost1
Copy link

cshost1 commented Apr 14, 2023

###NOT WORK
if ( $request ~* "my_log" ){ testcookie off; }

if ( $remote_addr = 111.11.11.111 ){
#return 308;
testcookie off;
}
###WORK
if ( $request ~* "my_log" ){ #testcookie off; }

if ( $remote_addr = 111.11.11.111 ){
#return 308;
#testcookie off;
}
testcookie off;

how testcookie off in IF... ?

@GrayHoax
Copy link

Why are you dont want to use testcookie_whitelist?

@cshost1
Copy link
Author

cshost1 commented Oct 13, 2023

Why are you dont want to use testcookie_whitelist?

because whitelist not work

@alyxto
Copy link

alyxto commented Feb 1, 2024

testcookie on/off can't be use in a if block

As described in the README you are suppose to use the testcookie_pass option.

Like this:

map $remote_addr $is_allowed_ip {
        1.1.1.1 1;
        default 0;
}

testcookie_pass $is_allowed_ip;

In general you are discouraged to use if statements in nginx as maps are more performant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants