Where is a gatehouse in a castle?

The gatehouse is the structure that defends the main gate, so the gatehouse is always at the entrance.