I feel for you! I used to struggle with nightmares too, despite being happy and well-adjusted during the day. I spent years trying different things. The only thing that helped (and also helped instantly) was reducing my exposures to Wireless Radiation.
You could start by turning off the WiFi router at night and turning off your phone, computer, tablets, etc. Airplane Mode no longer fully disables Wireless Radiofrequency Radiation on most cell phones, unless you also turn off the Bluetooth and mobile data. If you need to be reached overnight, you could put your cell phone ~6 feet away and still turn off the WiFi router and other devices.
Those small actions helped a ton, so I kept going. I bought an EMF canopy and have never had another nightmare, except on the nights when I slept elsewhere without one. I now connect to the internet using an Ethernet cord and USB adapter. I keep my devices in Airplane Mode while connected through Ethernet.
This website has some great tips to get started. It's run by the non-profit Environmental Health Trust:
http://healthytechhome.org
Feel free to reach out to me directly if you ever want to talk more about it. Reducing Wireless Radiation also made my anxiety go away, and my laundry list of inflammatory health conditions went into remission.
We are electromagnetic mammals, so it makes sense in hindsight. So much stuff is being broadcast wirelessly that is nightmare-ish in nature, so perhaps that influences our dreams.
You could also consider having an in-depth lab workup with an integrative doctor to make sure there aren't any nutrient deficiencies or other things that could be contributing. You're very wise for listening to your body and being proactive. <3