Nginx: block requests to external URLs [closed]

There's no way to match those requests with a location, since that style of request uri will be processed by nginx to strip out the scheme://host part.

if ($request ~* https?://) { return 444; }

In the server will match any request lines that contain http:// or https://. 444 is a special code to nginx, it will drop the connection without sending any sort of response. You can change that to a return 403 if you'd prefer.