The fundamental issue with balancing melee against ranged/spells is that melee has to take place at melee range. But what if ranged and spells did too?

Enter the Greater Globe of Invulnerability.

I envision this as an effect centered on the monster in question rather than a spell that has to be cast after the monster activates, as the latter would just make long range sniping even more appealing. It would function just like the spell Globe of Invulnerability except all non Positive energy spells would be blocked from entering, as well as all projectiles. Voila, now the developers can know that the only people damaging the monster will be in melee range, so they don't have to set its melee damage prohibitively high on the off chance it catches up to a kiter and needs to one shot them.

Notice if you will how unlike with blanket immunities, ranged and spellcasters can still contribute exactly as much DPS/CC/etc. as they otherwise would, they just have to be in melee range to do so, and I left the Positive loophole in so healers could still function normally since that's an archetype that's already unpopular.

Certainly end bosses would benefit from this, but sprinkling it throughout high end quests seems advisable as well. There could even be lesser varieties that were only active half the time, or only active for the first 20 seconds of a fight, or always active but a much larger area to give ranged/spells a little breathing room, etc.