How long you had it? I sometimes wake with a bad headache/neck pain and it isn't always because of how I sleep. I think last night's was from too much sugar yesterday (I was eating Life Savers as I was reading for several hours last night?). Do you wear glasses or do you now and you're close to 40? I know I had headaches/vision, etc. because I was doing a lot of reading and didn't have glasses yet and/or I was doing a lot of reading and my glasses weren't "right" (bent), etc.
Interesting, the knee pain in there too. I'd try to eat well today, get enough water/hydration and see if it got better and/or went away in a day or two. If it did not, I'd go see my doctor.