No. Firewall tools like iptables
can only block packets based on IP-level metadata (for example, refuse all connections except those apparently coming from a specific IP address range). The only identity you have for what browser a caller claims to be is the HTTP User-Agent:
header, and processing that involves a tool that actually knows how to handle the HTTP protocol. A reverse proxy built with a standard HTTP server like Nginx or Apache in principle could accomplish this.
From a security point of view, this isn't especially reliable. A command-line client tool like curl
can provide any User-Agent:
header it likes; if you look at Mozilla's documentation for User-Agent:
you'll notice that most popular browsers claim to be "Mozilla". MDN has an extended warning against checking this header value, which properly notes:
It's worth re-iterating: it's very rarely a good idea to use user agent sniffing. You can almost always find a better, more broadly compatible way to solve your problem!
If you really can't work around this problem in any other way, the MDN Browser detection using the user agent page describes how to do it. It also has good reasons to not do it, and some typical workarounds.