I'm trying block access to a portion of a path via Nginx, unless the source IP is within a specified range.
I think I've got this mostly working through much trial and error, but I seem to run into trouble when the path contains query strings:
Shouldn't work (unless within specified IP range):
/login
/login/
Should work (even publicly):
/login/anything-else
/login?username=user@whatever-domain.co.uk&type=pro
Current location block:
location ~ ^/(login|login/)$ {
allow 10.0.102.0/24;
deny all;
return 403;
}
Any suggestions would be most welcome, thanks!