Can you help me? I'm trying to block all requests outside my domain, and allow the request if a specified parameter exists
location ~* \.(mp4|vtt|mp3|mkv|avi)$ {
if ( $http_referer !~* 'mywebsite.com' ) { # check http_referer
if ($arg_78up = '') { #check if parameter 78up is empty
return 404; # then redirect to 404 page
}
}
}
And I'm getting this error when nginx starts:
nginx: [emerg] "if" directive is not allowed here in /etc/nginx/sites-enabled/default:17
What should I do to fix this issue? Thank you!
^means start of string,.+means one or more characters,:is a delimiter character, and then again we match one or more characters with.+, and finally we require the string ending with$. 0 is the value$refernotokvariable gets when the regular expression matches. – Tero Kilkanen Feb 28 '19 at 20:11nginx: [emerg] invalid number of the map parameters in /etc/nginx/nginx.conf:35. How can I fix it? – Vixarc Mar 08 '19 at 08:18