nginx: [emerg] “if” directive is not allowed here
February 24, 2019 03:47PM
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!



Edited 1 time(s). Last edit at 02/24/2019 03:47PM by vixarc.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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