Foods rich in magnesium, such as leafy greens, nuts, and seeds, can help alleviate headaches. Incorporating anti-inflammatory foods like fatty fish, berries, and ginger into your diet can also provide relief. Avoiding trigger foods, such as those high in histamine or nitrates, is equally important.