Answer the question
In order to leave comments, you need to log in
How to add header in NGINX only for specific IP?
I want to display a service header (cache information) only for a user with a specific IP (admin). Here is my configuration:
set $debug_ip_address "8.8.8.8";
location / {
set $is_debug 1;
if ($http_x_forwarded_for != $debug_ip_address) {
set $is_debug 0;
}
if ($is_debug) {
add_header X-Cache-File $cachefile;
add_header X-Cache-File $gzipcachefile;
}
try_files $gzipcachefile $cachefile $uri $uri/ /index.php?$args;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question