By means of universal similarity transformation, we derive the explicit spatial self-similar bright and dark soliton solutions of the cubic-quintic nonlinear Schrödinger equation with distributed coefficients and an external potential. An exact balance condition between the dispersion, nonlinearity, beam width and the gain/loss has been obtained. Under this parametric condition, we investigate the nonlinear tunneling effect of such solutions. We find that the amplitude and width of the self-similar waves are controllable while tunneling through the barriers and wells.