Welcome! Log In Create A New Profile

Advanced

Re: Response Header IF statement problem

February 14, 2018 05:07PM
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
Subject Author Posted

Response Header IF statement problem

wickedhangover February 14, 2018 09:12AM

Re: Response Header IF statement problem

Roman Arutyunyan February 14, 2018 10:02AM

Re: Response Header IF statement problem

wickedhangover February 14, 2018 10:04AM

Re: Response Header IF statement problem

webopsx February 14, 2018 10:08AM

Re: Response Header IF statement problem

wickedhangover February 14, 2018 04:04PM

Re: Response Header IF statement problem

webopsx February 14, 2018 04:39PM

Re: Response Header IF statement problem

wickedhangover February 14, 2018 04:46PM

Re: Response Header IF statement problem

pbooth February 14, 2018 05:16PM

Re: Response Header IF statement problem

wickedhangover February 15, 2018 08:04AM

Re: Response Header IF statement problem

wickedhangover February 15, 2018 08:24AM

Re: Response Header IF statement problem

Francis Daly February 16, 2018 07:38AM

Re: Response Header IF statement problem

wickedhangover February 16, 2018 08:52AM

Re: Response Header IF statement problem

Francis Daly February 16, 2018 10:40AM

Re: Response Header IF statement problem

webopsx February 14, 2018 10:03AM

Re: Response Header IF statement problem

wickedhangover February 14, 2018 10:18AM

Re: Response Header IF statement problem

webopsx February 14, 2018 05:07PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 288
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