How do I know when the nginx variable $http_referer is not set or empty?
I receive some requests that don't have a http referer. In nginx logs $http_referer appears like that: "-". What I am trying to do is to "return 403;" if the $http_referer is not set or empty as in this case.
Thanks!
http://nginx.org/en/docs/http/ngx_http_referer_module.html#valid_referers
valid_referers server_names ~.;
if ($invalid_referer) {
return 403;
}
How about this?
if ($http_referer ~ /^$/) {
return 403;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With