For a thorough overview of this you may like to watch this presentation by Dr. Catherine Bushnell, President of the Canadian Pain Society. It has information on thoughts, feelings the brain and pain. I recommend viewing the whole video, but if you want to jump to the area on thinking and feeling, you can start at 10 minutes.
Dr Howard Schubiner, in his book Unlearn Your Pain, describes a link between stress, strong emotions and chronic pain. You may also hear the term Central Sensitization to describe how the nervous system creates pain, remembers pain and maintains pain.
The link between how we think and feel and our pain experience cannot be overstated.
A less commonly addressed topic in persistent pain treatment is the connection between strong emotions and pain origins. The brain may sometimes trigger pain as a seeming protective mechanism when experiencing strong emotions (e.g. grief, humiliation, shame, trauma, fear).
Please view this video on nerve pathways and pain to make up your own mind on your possible underlying emotional origins for your pain.