You've almost given the answer in your question: If you have a starting headache due to little water or food, then your best option is to drink and/or eat.
Neither pills nor lifehacks should be used instead of drinking or eating.
And then it's another story what to drink or eat if not regular drinks or meals are available, or if the headache comes from other medical situations.
But normally, start with drinking and/or eating, and maybe relax and try not stressing.
lifehacks.stackexchange.com/users/4490/holroy
Eat salted nuts and wash them down with water.
There are three common causes that account for the bulk of all headaches (not counting migraines).
They are lack of potassium, lack of protein, and dehydration.
Salted nuts alleviate the first two and water resolves the third.
Results in just a few minutes.
By way of notes, if you were inclined to argue about muscle tension headaches that's what potassium does.
lifehacks.stackexchange.com/users/4620/Stephen Goodman
Cold Compress Soak a small towel in cold water, wrap it around an ice pack, lay down, and hold it on your forehead.
Or, depending on the type of headache...
Hot Compress Soak a small towel in as-hot-as-possible-but-it-will-not-burn-you water, lay down, and hold it on your forehead.
Tension headaches can also be relieved with caffeine (thus why it's various pain relievers).
Drinking hot, caffeinated tea will doubly help.
lifehacks.stackexchange.com/users/15/Mooseman
Hydration - water is best, also try sports drink with electrolytes Coffee helps if you are into that.
Accupressure/reflexology REALLY WORKS
I prefer the hand pressure point.
lifehacks.stackexchange.com/users/4568/Sonicthoughts
It is hard to recommend something specifically that will work for you but based on the information you gave, I think it is worth it to looking into trying out a pair of FL41 tinted glasses.
Large number of people (including myself) suffer from migraines because of photophobia, blepharospasm, and any other light sensitivity "syndromes".
We are just more likely to have eye strain due to certain light wavelengths.
Tinted glasses help block these wavelengths and therefore, keep your migraine from starting in the first place.
My migraines were always triggered at work (fluorescent lighting and computer screens) as well as on really sunny days.
I tried out a pair of tinted glasses and it was almost instantaneous for them disappearing.
Again, not sure if this is the case or trigger for you but it is an option you can explore.
Note: If you do so though, make sure you get "real" FL41 glasses...I guess not all have the same tint density (source: https://www.axonoptics.com/migraine-causes/ )
lifehacks.stackexchange.com/users/10332/Health Through Adventure
Word of warning: this is an extremely impractical solution.
At one of my old jobs we had an Anechoic chamber .
The result of being in one of these is that is is extremely quiet and when the lights are off, extremely dark.
One of my colleagues used to swear that five minutes sitting in it with the lights off would cure any headache.
I can anecdotally confirm.
A less extreme/more practical alternative could be keeping your head under a duvet, curtains drawn, earplugs in.
lifehacks.stackexchange.com/users/4533/dav_i
Bend over at the waist, let your arms hang loose, tuck your chin in and let the blood rush to your head.
Hold for 10-20 seconds.
Repeat as necessary.
lifehacks.stackexchange.com/users/4562/jocky
I find that regulating the blood to the brain helps with some headache causes.
Something like: Putting a slight pressure on both temples and holding that for 1 minute on, 1 minute off helps.
Placing your index finger and thumb on the bridge of your nose (there's a small blood vessel on either side, I believe) Other than that, though as others have said, water (sips, not gulps) helps.
lifehacks.stackexchange.com/users/4800/jbutler483
A headache can be caused by withdrawal symptoms if you are "addicted" to caffeine.
See this article from the Smithsonian.
If you are addicted, try slowly reducing your intake of caffeine over a week and then when you do not drink you will not suffer "the dreaded caffeine withdrawal headache."
lifehacks.stackexchange.com/users/10449/Avrohom Yitzchok
I've experienced this sometimes when I go for hours without water or little food and suddenly I experience a headache that gradually gets worse as time goes on. Until now I used to just pop a pill and get it over with, but I've always looked for alternatives and frankly the internet is filled with data over data. So I need to be recommended a will-work-in-any-scenario kind of solution.
How to quickly cure headaches without medicine
lifehacks.stackexchange.com
<substitute-tool><personal-care><comfort>
lifehacks.stackexchange.com/questions/6169
lifehacks.stackexchange.com/users/2339/SandyShores
There are a few ways to cure a headache without medicine and possibly the most effective is to eat or drink, perhaps eating salted nuts and drinking water. Alternatively, you could bend over to allow the blood to rush to keep your head under a duvet with the curtains drawn and some earplugs in. Applying light pressure to both temples and holding this 1 minutes on, 1 minute off, could also be effective. Wearing tinted glasses or applying a cold compress might also help. The options are to eat and/or drink something, relax, eat salted nuts with water, lie down with a cold compress, try accupressure or reflexology, try tinted glasses, try 10-20 second bends, apply slight pressure to your temples 1 minute at a time, lie down under a duvet with earplugs.
Get something to eat and/or drink - and try not stressing. Eat salted nuts washed down with water.   Lie down with a cold compress on your forehead and drink hot tea. Drink electrolytes or coffee and try accupressure or reflexology. Try tinted glasses - you may have migraine. Try sitting in an anechoic chamber or lying under a duvet with curtains drawn and earplugs in. Bend over for 10-20 seconds with arms loose and chin in - repeat this as needed. Put slight pressure on your temples - 1 minute on and 1 off - and also drink water. You may have caffeine addiction, in which case slowly reduce your intake.