We generalize the Power-Zineau-Woolley transformation to obtain a canonical Hamiltonian of cavity quantum electrodynamics for arbitrary geometry of boundaries. This Hamiltonian is free from the A-square term and the instantaneous Coulomb interaction between distinct atoms. The single-mode models of cavity QED (Dicke, Tavis-Cummings, Jaynes-Cummings) are justified by a term by term mapping to the proposed microscopic Hamiltonian. As one straightforward consequence, the basis of no-go argumentations concerning the Dicke phase transition with atoms in electromagnetic fields dissolves.