Onset of solutions with internal layers approaching the domain boundary