Nginx retrieves a value from a variable or any string

Is there an alternative to using If to extract a value from a variable in Nginx configuration files?

i.e

if ($http_referer ~* (?<=url=)([\w-.]*)(?=/) ){ set $proxied $1; rewrite (?<=/)(.+\.(css|jpg|png|gif|js)) http://$proxied/$1 redirect; } 

thanks

+4
source share
1 answer

Yes. http://nginx.org/r/map

 map $http_referer $proxied { default example.com; "~*(?<=url=)(?<p>[\w-.]*)(?=/)" $p; } 
+4
source

Source: https://habr.com/ru/post/1434601/


All Articles