The Sentinel feat allows me an opportunity attack against an enemy who attacks an ally within reach.
Does this still apply if said attack was an opportunity attack made by the enemy, because my ally was fleeing?
The Sentinel feat (PHB, p. 169-170) specifies that (emphasis mine):
When a creature within 5 feet of you makes an attack against a target other than you (and that target doesn't have this feat), you can use your reaction to make a melee weapon attack against the attacking creature.
The only conditions for triggering Sentinel are:
It does not matter what caused the creature to make this attack in the first place so you can use Sentinel.
It is important to note, however, that this attack granted by Sentinel using your reaction is not considered an Opportunity Attack. For example, you can't combine this with the War Caster feat to use a spell, or use the Tunnel Fighter fighting style to have Sentinel not use your reaction.