https://www.youtube.com/watch?v=KwwMJEiybb4
The stock location for most Forester ECU's ( except 2.0 SF models ) is under a steel panel in the passenger's footwell. This is easily accessed by popping off the sill kick panel and pulling up the carpet a bit.

Then you just undo a couple of bolts and the ECU comes out. Before unplugging it I'd recommend disconnecting the battery.
To remove the glovebox, simply open it, empty out your stuff and undo all the screws. It'll pretty much fall off then.
You could try & fit the ECU behind the glovebox but there just isn't enough space. The simplest fix is to make a cut out in back of compartment - procede to prize off the owner's manual holder, mark out approx location of ECU and cut a suitable rectangular hole in the back of the glovebox for the rear of the ECU to poke through.

Mount the ECU by marking through the holes of ECU fixing plate & drill holes - bolt / screw / Zip tie to top of box.
Can refit the shelf if your inclined ...

One thing you will need to do ( if your car has cruise control ) is undo the two bolts holding the module on and let it fall down - this is necessary to re-route the ECU cabling. You can then cable tie it back up under the dash, adjacent to the ECU wiring bundle.

Basically, this mod will stop you drowning your ECU if you get water in the car ( up to a certain level ) - it increases the wading depth by around 20cm ( airbag module is under stereo ).

Notes : Most of the above info has been extracted from this site : https://www.offroadsubarus.com/threads/5920/
Might come back & edit / add to later ...
Cheers, Bantum ...