We theoretically study the Josephson effect in a quantum anomalous Hall insulator (QAHI) nanoribbon with a domain wall structure and covered by the superconductor. The anomalous Josephson current, the nonzero supercurrent at the zero superconducting phase difference, appears with the nonzero magnetization and the suitable azimuth angle of the domain wall. Dependent on the configuration of the domain wall, the anomalous current peaks in the Bloch type but disappears in the Néel type because the y-component of magnetization is necessary to break symmetry to arouse the anomalous current. The phase shift of the anomalous current is tunable by the magnetization, the azimuth angle, or the thickness of the domain wall. By introducing a bare QAHI region in the middle of the junction which is not covered by the superconductor, the anomalous Josephson effect is enhanced such that the phase shift can exceed π. Thus, a continuous change between 0 and π junctions is realized via regulating the configuration of the domain wall or the magnetization strength. As long as an s-wave superconductor is placed on the top of the QAHI with a domain wall structure, this proposal can be experimentally fabricated and useful for the phase battery or superconducting quantum bit.