Context. There is compelling evidence that active galactic nuclei (AGNs) in high-density regions have undergone a different evolution than their counterparts in the field, indicating that they are strongly affected by their environment. However, we still lack a comprehensive understanding of the dominant mechanisms that trigger the nucleus and the processes that drive the evolution of AGNs in clusters. Aims. To investigate (and possibly disentangle) the various factors that may affect the prevalence of AGNs in cluster galaxies, we selected a sample of 19 thoroughly studied X-ray-selected galaxy clusters from the LoCuSS survey. All these clusters are considered massive, with M500 ≳ 2 × 1014 M⊙, and span a narrow redshift range between z ∼ 0.16 and 0.28. Methods. We divided the cluster surroundings into two concentric annuli with a width of R500 radius. We considered the first annulus as the central cluster region and the second as the outskirts. We further divided the cluster sample based on the presence of infalling X-ray-detected groups, cluster mass, or dynamical state. We determined the AGN fraction in cluster galaxies of the various sub-samples by correlating the X-ray point-like sources selected from the 4XMM DR10 catalogue with the highly complete spectroscopic catalogue of cluster members obtained with Hectospec. We subsequently used the optical spectra to determine the type of nuclear activity and we visually inspected the host morphology for indications of galaxy mergers or other interactions. Results. We found that the X-ray AGN fraction in the outskirts is consistent with the field, but it is significantly lower in cluster centres, in agreement with previous results for massive clusters. We show that these results do not depend on cluster mass, at least within our cluster mass range, nor on the presence of X-ray-detected infalling groups. Furthermore, we did not find any evidence of a spatial correlation between infalling groups and AGNs. Nevertheless, a significant excess of X-ray AGNs is found in the outskirts of relaxed clusters at the 2σ confidence level, compared both to non-relaxed clusters and to the field. Finally, according to the literature, the fraction of broad- to narrow-line AGNs in clusters is roughly consistent with the field. However, broad-line AGNs may be preferably located in cluster centres. In the outskirts, the optical spectra of X-ray AGNs present narrow emission lines or they are dominated by stellar emission. Conclusions. Our results suggest that the mechanisms that trigger AGN activity may vary between cluster centres and the outskirts. Ram pressure can efficiently remove the gas from infalling galaxies, thereby triggering AGN activity in some cases. However, the reduced availability of gas globally diminishes the fraction of AGNs in cluster centers. The surplus of X-ray AGNs identified in the outskirts of relaxed clusters may be attributed to an increased frequency of galaxy mergers, a notion that is further supported by the disturbed morphology observed in several galaxies.