Finite temperature Casimir energy in closed rectangular cavities: a rigorous derivation based on a zeta function technique