Many dogs are uncomfortable with new people or pets approaching them or reaching towards them, especially if in the past, this has predicted negative or scary things like being pushed past their boundaries. For a lot of dogs, this scary feeling makes them want the person to go away. They begin to show natural behaviors that mean “go away” like barking, growling, snapping, and looking scary. Most of the time, when they do this the scary person goes away, so they learn that this is a great way to get some space. The goal with any pet like this would be to make them more comfortable with new people coming by associating their approach and presence with positive things. This starts with making sure that new people or dogs do not predict the dog being pushed past their boundaries (they do not pet them if they do not want it, and when they show stress signals the people give them space ). If the dog is giving you all the signs that they are uncomfortable, it is important for you to tell the stranger to give him some space or just ignore them because most people will not look for these signals. Do not feel bad for speaking up for what your dog needs and remember that the more times that people push their boundaries, it teaches the dog that they have to be louder in their communication of those boundaries, making those behaviors worse.
The next stage is teaching the dog that these new people and pets mean good things. This is different for each dog, as different pets find different things rewarding but most dogs do like food (especially tasty food), so feeding them treats when they notice strangers or having strangers feed them good treats without petting them is a good way to help them feel better. This is called counter-conditioning. During counter-conditioning exercises, it is important that the dog is not already past their threshold (more info on this
here) because if the dog is already reacting, they will not learn this new association of new people = good things are coming.
Sometimes, dogs have to be introduced to other pets or people slowly no matter how much we work with them. As long as you find a system that works for you and doesn't make the more uncomfortable, stick with it! The more predictable meetings with new people, the less the dog will feel the need to defend themselves against what could happen since they already know what will happen. Here are some links that will help you understand this more and give you tips and tricks: