Nginx configuration


#1

I’m trying to throw an error(403) if request is for api. So I created map like this map $uri $is_webpage { ~\.(html|htm|js) 0; #web pages default 1; #apis }

map $is_webpage $error_code { 0 return 302 $location_page/static/login.html; default return 403; }

and in location block I’m specifying $error_code but it is not working. So can you please help me with this. I am not allowed to use if.


#2

@Sushant91265 if you want to throw just 403 to a particular request, you can try

location = /myapi { return 403; }


#3

THanks


#4