Re: Response Header IF statement problem

2018-02-14 Thread webopsx
Hi,

Yes NGINX can inspect the header, See the following full example. It will
check for the match of "true" case-insensitive. I am simulating your backend
on port 81. Does this make sense?

map $upstream_http_x_secured_page $nocache {
~*true  "1";
default "";
}

upstream backend {
server 127.0.0.1:81;
}

server {
listen   80;
server_name  localhost;

#charset koi8-r;
#access_log  /var/log/nginx/log/host.access.log  main;

location / {
proxy_no_cache $nocache;
add_header X-No-Cache-Status $nocache;
proxy_pass http://backend;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}

}

server {

listen 81;

location / {
add_header X-Secured-Page "True";
return 200 "OK\n";
}

}


# testing

root@dev:/etc/nginx/conf.d# curl -I localhost   

   
HTTP/1.1 200 OK
Server: nginx/1.13.7
Date: Wed, 14 Feb 2018 21:59:55 GMT
Content-Type: application/octet-stream
Content-Length: 3
Connection: keep-alive
X-Secured-Page: True
X-No-Cache-Status: 1

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,278558,278578#msg-278578

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Response Header IF statement problem

2018-02-14 Thread webopsx
Hi,

The map is processed on each request and should be very consistent. 

I thought you wanted to disable cache on the existence of a response header,
not a request header.

Otherwise I think we need more information to understand, such as how are
you testing? Perhaps paste your full configuration here after removing any
sensitive text.

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,278558,278576#msg-278576

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


Re: Response Header IF statement problem

2018-02-14 Thread webopsx
You can use map for this...

 - http://nginx.org/en/docs/http/ngx_http_map_module.html#map

map $upstream_http_x_secured_page $nocache {
"search string" "1"
default "";
}

location /foo {
...
proxy_no_cache $nocache;
}

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,278558,278563#msg-278563

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx