I’m happy to hear that yoga has helped you too. Headaches are a pain in the head, and everywhere else.
However I would suggest you try to do sirshasana the right way with the support of a wall, with your focus being on calm breathing. Hanging your head over the bed may or may not cause stresses elsewhere in your body. I don’t know for sure but I wouldn’t take the risk. Another caution: avoid doing the asana after exercise, as the heated blood could have weird effects on your brain. Come to think of it, maybe you should stick to keeping it to less than five minutes for the same reason. Good Luck!