Two magnetic impurities in a spin chain