Welcome! Log In Create A New Profile

Advanced

return 503, si tengo 'custom_header'.

Posted by thegaby 
return 503, si tengo 'custom_header'.
September 12, 2014 05:01PM
Estoy queriendo armar una configuracion para retornar un 503, en caso de que el request contenga un header custom, por ejemplo "custom_header".

No estoy pudiendo lograr que la condicion se cumpla:

Config:
--------------------------------------------------------------
server {
server_name 127.0.0.1;
listen 80;
charset utf-8;

root /var/www/man;
index index.html;

if ($http_custom_header) { return 503; }

location / {
allow all;
}

error_page 503 /503.html;
location = /503.html {
allow all;
}
}
--------------------------------------------------------------

No funciona.

La peticion la genero asi:

curl 127.0.0.1 -H 'http_custom_header' -i

Y Me devuelve:

HTTP/1.1 200 OK
Server: nginx

--------------------------------------------------------------

Si en vez de armar la condicion con ese header, consulto por un header standar, por ejemplo por http_x_forwarded_for, si logro que la condicion se cumpla:

En la config, pongo:
if ($http_x_forwarded_for) { return 503; }

curl 127.0.0.1 -H 'x-forwarded-for: LALA' -i

HTTP/1.1 503 Service Temporarily Unavailable
Server: nginx

--------------------------------------------------------------

Alguna idea ? No esta soportado consultar un header custom ?

Gracias!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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