Pray. Read peaceful poems about life and hope. Put your heart in your words and pray to god to help you. Now im not one of those crazed religious people but once i was in the same situation and i was young and dumb thinking being an atheist was the sh*t and praying my heart out worked for me
Try replacing the details of the dream with tangible thoughts of things that you find pleasant. I know that is not easy to do, but, if You can compartmentalize and slowly make the mental and emotional transition , You should soon become able to overcome the fears that are keeping you from resting peacefully
I wonder what your nightmare was. Don't be scared we all get scary nightmares sometimes. sometimes dreams or nightmares we don't wish to have. Try and clean the "bad energy" out of your bed room. clean your bedding in the wash machine/dryer. Clean your room get a fan and open your window blow the bad dreams out the window. Dont watch scary movies/or read material that is unhelpful or against your morals.
I agree with Lilith 777 praying helps quite a lot but you can't just do it willy nilly you really have to mean it I don't want to go all religious but calling on Jesus and pleading the blood of Christ can guaranteed fix your problem