  We obtain an asymptotic formula for all moments of Dirichlet $L$-functions
$L(1,\chi)$ modulo $p$ when averaged over a subgroup of characters $\chi$ of
size $(p-1)/d$ with $\varphi(d)=o(\log p)$. Assuming the infinitude of Mersenne
primes, the range of our result is optimal and improves and generalises the
previous result of S. Louboutin and M. Munsch (2022) for second moments. We
also use our ideas to get an asymptotic formula for the second moment of
$L(1/2,\chi)$ over subgroups of characters of similar size. This leads to
non-vanishing results in this family where the proportion obtained depends on
the height of the smallest rational number lying in the dual group.
Additionally, we prove that, in both cases, we can take much smaller subgroups
for almost all primes $p$. Our method relies on pointwise and average estimates
on small solutions of linear congruences which in turn leads us to use and
modify some results for product sets of Farey fractions.
