Brad Lyons' header saw Aberdeen take a surprise first half lead against Rangers in the Scottish Premiership.