The best way to stop a T2 trooper rush is to mass troopers. Troopers counter anything available in T2 and you can rush with them yourself, so it's usually best to build as many as you can, especially in a 1v1, as trooper wars are nearly always guaranteed. If you can do it, a good way to stop a rush is to rush your opponent before they can rush you. Even if you're both rushing at the same time, it can pay to keep your troopers attacking their workers rather than pulling them back to defend your own workers. Always build a war centre as soon as you can, as the upgrades are important in trooper wars.
On high bantha/nerf maps they might try to do a fast T3 strike rush. You should suspect this if you don't get trooper rushed soon after they get to T2. If they go T3 without trooper rushing, strikes will almost certainly be on the way in a minute or two. By this time you should already have decided how you're going to play it, as you know fast T3s are possible as soon as your scout starts finding lots of banthas.
You could try to do a fast T3 yourself and try to get your strike rush in first. This is risky because you could be in trouble if your opponent goes for a trooper rush instead of a fast T3. Preparing to meet a trooper rush diverts resources and slows down your T3 time, which means if they don't go for trooper wars their strike rush will be faster than yours.
A safer option is to try a trooper rush before they can go T3. This should be effective if they're going for a fast T3 as their defences might not be very good. I've seen good players doing a 14 minute T3, but without a turret or even a troop centre! If they go for trooper wars you'll still be ready for them.
In either case, you can use mounties and/or grenaders to defend from strikes. A turret is also vital as strikes take a lot of damage from garrisoned turrets. Strike wars can be very micro intensive. You need to keep your mounties within the strikes' minimum range and try to chase as many of them as you can at the same time (easier said than done!). If all your mounties gang up on one strike, the other strikes will stand off and shoot them. Once there are more than 4-6 strikes, using mounties gets difficult. Grenaders are more useful against larger numbers of strikes. You'll need at least 3 grenaders (which is a lot of nova) as a grenader kills a strike in 3 shots but a strike kills a grenader in 2 shots. If the strikes aren't spread out, the area effect works to your advantage.
Of course if they can rush before you can T2 you're screwed whatever you do.
Ultimately, to get good at countering rushes, you need to get good at doing rushes yourself. If good rushers play each other, it can lead to a very finely balanced game which goes on for a long time.