Sorry for posting here - don’t know for sure if it’s the right place.
I have an issue:
I use nginx as reverse proxy, but I don’t always know the domain name for
which I’m serving, so my setup looks like this:
server_name _ $host 0.0.0.0;
The “$host” string here means exactly “$host”. There is no
variable expansion for server_name (expect for a special name
“$hostname”, which isn’t actually a variable but a special name).
Most likely requests are handled in the sever{} block in question
as it’s used as a default server.
I try to block invalid referers but when I try to add $host to
valid_referers - it doesn’t seem to work:
if ($temp ~* “^(.*):http?://\1”) {
set $test “${test}B”;
}
Just a side note: this statement isn’t needed. Both http and
https schemes are allowed by a “https?” in the regular expression
I provided, “?” makes preceeding character option.
if ($temp ~* “^(.*):https?://\1”) {
set $test “${test}C”;
}
if ($test = ABC) {
return 444 ;
}
It is always returning 444 … what am I doing wrong?!
You probably mean to write
if ($test = A) {
return 444;
}
instead, as your initial message suggests you want to allow
requests where Referer matches Host.