In this paper, we study the diffusive shock acceleration of cosmic-ray protons and nuclei, taking into account all the relevant interaction processes with photon backgrounds. We investigate how the competition between protons and nuclei is modified by the acceleration parameters such as the acceleration rate, its rigidity dependence, the photon density and the confinement capability of the sources. We find that in the case of interaction-limited acceleration processes protons are likely to be accelerated to higher energies than nuclei, whereas for confinement-limited acceleration nuclei are accelerated to higher energies than protons. Finally, we discuss our results in the context of possible astrophysical accelerators, and in the light of recent cosmic-ray data.