I had very similar issues, both as a kid and an adult. I now take 500mg of Magnesium (Malate or Glycinate. NOT Citrate, as that is a laxative) nearly every night, and my headaches are almost completely gone now. I still get one every once in a while, but it's infrequent enough that I no longer worry about my use of Ibuprofen to manage it.