In this work we study the Casimir effect for massless scalar fields propagating in a piston geometry of the type $Itimes N$ where $I$ is an interval of the real line and $N$ is a smooth compact Riemannian manifold. Our analysis represents a generalization of previous results obtained for pistons configurations as we consider all possible boundary conditions that are allowed to be imposed on the scalar fields. We employ the spectral zeta function formalism in the framework of scattering theory in order to obtain an expression for the Casimir energy and the corresponding Casimir force on the piston. We provide explicit results for the Casimir force when the manifold $N$ is a $d$-dimensional sphere and a disk.