  We study penetration of interstellar cosmic rays (CRs) into molecular clouds
surrounded by nonuniform diffuse envelopes. The present work generalizes our
earlier model of CR self-modulation (Ivlev et al. 2018, Dogiel et al. 2018), in
which the value for the envelope's gas density where CRs excite MHD waves was
treated as a free parameter. Now, we investigate the case where the density
monotonically increases toward the center. Assuming that CRs are relativistic,
we obtain a universal analytical solution which does not depend on the
particular shape of gas distribution in the envelope, and self-consistently
derive boundaries of the diffusion zone formed within the envelope, where CRs
are scattered at the self-excited waves. The values of the gas density at the
boundaries are found to be substantially smaller than those assumed in the
earlier model, which leads to a significantly stronger modulation of
penetrating CRs. We compute the impact of CR self-modulation on the gamma-ray
emission, and show that the results of our theoretical model are in excellent
agreement with recent observations of nearby giant molecular clouds by Yang et
al. (2023).
