A rescue ship drifting afloat the Mediterranean, with more than 600 onboard, was denied the right to dock in Italy and Malta - the two closest countries.