How would I best filter traffic based on the request URI? What I'd like to do is limit access to the script some-script.php when only a certain argument list is given. For instance, allow everyone to reach user_info with associated user_id value, but deny everyone access to action=admin_login unless their IP address is on the LAN.
I know if is evil and allow all won't work as shown below but I can't seem to find what I'm wanting to do.
location ~* /live/some-script\.php {
// allow "?action=user_info&user_id=[0-9]{1,6}"
if ($request_uri ~* "action=bwg_frontend_data" ) {
allow all;
}
// deny everyone access to "?action=admin_login", but allow 192.168.100.0/24
if ($request_uri ~* "?action=admin_login.*")
{
allow from 192.168.100.0/24;
}
return 403;
}
$arg_actionfor the matching instead ofquery_string. Then nginx will extract the argument value and themapcan be simpler. – Tero Kilkanen Jan 08 '19 at 22:23map{}in my config. Does this configuration item need to be added in a specific config section? The file in my post above is actually in an "include" file which gets pulled in from theserversection insites-enabled/site.ssl. – Server Fault Jan 18 '19 at 18:16http.d/request_maps.confdirectory/file and included it in the nginxhttpsection. This seems to pull it in the correct way. I want minimal edits innginx.confso ubuntu upgrades don't whack all my changes. – Server Fault Jan 18 '19 at 18:46return 410in theifblock, but notallow all. Does this have something to do with the include location as well? tried moving the include into thehttpblock but then it was upset with thelocationdirective. – Server Fault Jan 18 '19 at 19:31