As close as possible & practical. However NOT inside a small enclosed space WITH the battery where gas could build up. Although most unlikely you should never risk putting ANY electrical equipment which has a potential to create a spark in an evironment which could possibly become explosive. With AGM/Gel batteries the risk is minimal, but they can gas in some situations. The risk is far higher with wet batteries.
Wet batteries should never be inside the vehicle.