Basically, this. Flamethrowers are nasty weapons, but they do have some serious limitations when it comes to fuel capacity. This is
sort of why they kinda ceased to exist in most places - although people can still recognise the value of incendiary weapons, the United States for example moved on to things like the M202 FLASH, the rocket launcher that we most famously see Arnie slogging around with in Commando...
...which basically marries the flamethrower and missile launcher together by creating a missle that just douses the target area in incendiaries. All the terrifying effect of a flamethrower, but with far fewer issues - easier to handle, no exposed tanks, much greater range, and quickly reloaded as needed. In their usual form, flamethrowers just have a ton of baggage that is best gotten around of by designing weapons that keep the strengths of a flamethrower, but don't have those issues. In this case, if you really wanted some kind of close in anti-infantry system, you could
potentially create some kind of remotely detonated explosive on the outside of the hull, scattering something like white phosphorous over the surrounding area. That'd be much easier to run and less mechanically complex (it's basically just a bomb with WP inside), but a) at that point the concept is probably a bust anyway because infantry might very well have AT gear they can use from afar, b) anything going wrong with this system is liable to kill a
lot of friendly infantry that might otherwise protect you from said enemy attackers, c) there's the serious risk of this actually destroying the tank, because if I remember right there's the issue of the fuel/phosphorous being sucked up into the engine, or as the US realized in WW2, that it can be used on tanks because turret ventilation systems could suck the fumes inside the tank, as is mentioned on Wikipedia...
...and make the crew think that their tank is on fire. All in all, the best protection you can probably get in this case is just...your own infantry? They've got guns - why not use them?
But if you must have something fancy, might I suggest taking a page out of this Sherman's book?
If not fire, why not spikes? It works for Mad Max?