Did you know that stress can hurt? Studies show that depression and anxiety can lower your pain threshold, potentially making minor aches and pains into major problems. If you've ever noticed your back pain getting worse when your job gets more stressful, you've seen this first hand. On top of that, a common symptom of mood and anxiety disorders is something called somatization, a phenomenon where the body produces physical symptoms (pain, stiffness, digestive problems) as a manifestation of stress.
This is very different from saying that your pain is "all in your head." The pain is real, and it's not something that you can just ignore, or think your way out of. Rather, it's a case where resolving your pain will also require you to deal with the psychological factors that are causing or exacerbating it.