Hi, welcome to the forum.
You look at the notes that make up each chord, and put them together to make the scale that you use to solo with. You can use the reverse scale finder link at the top of the page to do that, which saves quite a bit of time.
The chords you said though don't go well together, because the notes that make up the chords don't make a particular scale. It doesn't mean you can't use them, but finding a scale to use to solo with would be hard.
To give you an easy example, using the chords D, G, A and Bm:
D G A B
F# B C# D
A D E F#
When you "add up" all the notes in those chords you get the notes D, E, F#, G, A, B and C#, which are the notes of the Dmaj scale.
For soloing over D, use D major. For soloing over G, use G lydian. For soloing over A, use A mixolydian. And for soloing over Bm, use A aeolian (the natural minor). All these modes have the same notes as D major, but they start on a different note, which is the same note as the root of the chord. You can check out how to play these by using the scales link at the top of the page.
Hope this helps
[to admin: could we have some kinda way of putting up user-made lessons? this question about scales comes up loads, and if someone made a lesson for it then people could just go to that rather than ask here, and then they can ask here, or even better on a discussion page especially for that particular lesson, if they don't understand it. I know its taking away from the forum format a bit, but there are loads of topics on here that are covered time and time again. what do you guys think?]