Proxy Bypass only specific IP

Maxim Dounin mdounin at mdounin.ru
Tue Jun 24 14:23:38 UTC 2014


Hello!

On Tue, Jun 24, 2014 at 06:38:59AM -0400, TheBritishGeek wrote:

> I have tried 
> 
>         if ($remote_addr ~ "^(1.1.1.1|a:b:c:d::1:2)$")
>         {
>             proxy_cache_bypass $http_secret_header;
>         }
> 
> But is does not pass testing
> 
> nginx: [emerg] "proxy_cache_bypass" directive is not allowed here

You have to set a variable as appropriate, and then use it in the 
proxy_set_bypass directive.

    if (...) {
        set $bypass $http_secret_header;
    }

    proxy_cache_bypass $bypass;

Also, apart from "if" checks, it may be good idea to consider geo 
and map blocks, see here:

http://nginx.org/en/docs/http/ngx_http_geo_module.html
http://nginx.org/en/docs/http/ngx_http_map_module.html

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list