The way to defeat it (According to the captain) is a series of short safety stops where you pause momentarily during ascents to let your system equilibrium recover.
If I feel a headache coming on underwater during a shallow dive where I'm swimming around coral heads & changing direction a lot, I will try pausing for a minute to see if recovering my equilibrium helps reduce the headache.
Typically my headache comes first. Don't ask me about nausea, you know I'm usually nauseous while in the water!