We consider compact ${U}^{\ensuremath{\kappa}}(1)$ gauge theory in $3+1$ dimensions with a general $2\ensuremath{\pi}$-quantized topological term ${\ensuremath{\sum}}_{I,J=1}^{\ensuremath{\kappa}}\frac{{K}_{IJ}}{4\ensuremath{\pi}}{\ensuremath{\int}}_{{M}^{4}}{F}^{I}\ensuremath{\wedge}{F}^{J}$, where $K$ is an integer symmetric matrix with even diagonal elements and ${F}^{I}=d{A}^{I}$. At energies below the gauge charges' gaps but above the monopoles' gaps, this field theory has an emergent ${\mathbb{Z}}_{{k}_{1}}^{(1)}\ifmmode\times\else\texttimes\fi{}{\mathbb{Z}}_{{k}_{2}}^{(1)}\ifmmode\times\else\texttimes\fi{}\ensuremath{\cdots}$ 1-symmetry, where ${k}_{i}$ are the diagonal elements of the Smith normal form of $K$ and ${\mathbb{Z}}_{0}^{(1)}$ is regarded as a $U(1)$ 1-symmetry. In the ${U}^{\ensuremath{\kappa}}(1)$ confined phase, the boundary can have a phase whose infrared (IR) properties are described by Chern-Simons field theory. Such a phase has a ${\mathbb{Z}}_{{k}_{1}}^{(1)}\ifmmode\times\else\texttimes\fi{}{\mathbb{Z}}_{{k}_{2}}^{(1)}\ifmmode\times\else\texttimes\fi{}\ensuremath{\cdots}$ 1-symmetry that can be anomalous. To show these results, we develop a bosonic lattice model whose IR properties are described by this continuum field theory, thus acting as its ultraviolet completion. The lattice model in the aforementioned limit has an exact ${\mathbb{Z}}_{{k}_{1}}^{(1)}\ifmmode\times\else\texttimes\fi{}{\mathbb{Z}}_{{k}_{2}}^{(1)}\ifmmode\times\else\texttimes\fi{}\ensuremath{\cdots}$ 1-symmetry. We find that the short-range entangled gapped phase of the lattice model, corresponding to the confined phase of the ${U}^{\ensuremath{\kappa}}(1)$ gauge theory, is a symmetry protected topological (SPT) phase for the ${\mathbb{Z}}_{{k}_{1}}^{(1)}\ifmmode\times\else\texttimes\fi{}{\mathbb{Z}}_{{k}_{2}}^{(1)}\ifmmode\times\else\texttimes\fi{}\ensuremath{\cdots}$ 1-symmetry, whose SPT invariant is $\phantom{\rule{1.0pt}{0ex}}{e}^{\phantom{\rule{1.0pt}{0ex}}i\phantom{\rule{1.0pt}{0ex}}\ensuremath{\pi}{\ensuremath{\sum}}_{I,J}{K}_{IJ}{\ensuremath{\int}}_{{\mathcal{M}}^{4}}{B}_{I}\ensuremath{\smile}{B}_{J}+{B}_{I}\underset{1}{\ensuremath{\smile}}\phantom{\rule{1.0pt}{0ex}}d{B}_{J}}\phantom{\rule{1.0pt}{0ex}}{e}^{\phantom{\rule{1.0pt}{0ex}}i\phantom{\rule{1.0pt}{0ex}}\ensuremath{\pi}{\ensuremath{\sum}}_{I<J}{K}_{IJ}{\ensuremath{\int}}_{{\mathcal{M}}^{4}}\phantom{\rule{1.0pt}{0ex}}d{B}_{I}\underset{2}{\ensuremath{\smile}}\phantom{\rule{1.0pt}{0ex}}d{B}_{J}}$. Here, the background $\mathbb{R}/\mathbb{Z}$-valued 2-cochains ${B}_{I}$ satisfy $\phantom{\rule{1.0pt}{0ex}}d{B}_{I}={\ensuremath{\sum}}_{I}{B}_{I}{K}_{IJ}=0\phantom{\rule{3.33333pt}{0ex}}mod\phantom{\rule{0.28em}{0ex}}1$ and describe the symmetry twist of the ${\mathbb{Z}}_{{k}_{1}}^{(1)}\ifmmode\times\else\texttimes\fi{}{\mathbb{Z}}_{{k}_{2}}^{(1)}\ifmmode\times\else\texttimes\fi{}\ensuremath{\cdots}$ 1-symmetry. We apply this general result to a few examples with simple $K$ matrices. We find the nontrivial SPT order in the confined phases of these models and discuss its classifications using the fourth cohomology group of the corresponding 2-group.