I had written a c++ server to process client requests.
I would parse the request url after I get the request, and check whether the request url is valid, for example, the request is a invalid one if it does not start with "/temp".
afterwards I used nginx to stop these invalid request(you could set the valid request url format in the nginx.conf) before sending to the c++ server, and it worked well.
maybe you could try nginx.