Photon-mediated atom-atom interaction in a confocal cavity