In this work, we employ a Hamiltonian-based procedure to derive a generalized Nose barostat, which generates trajectories that rigorously satisfy the statistical mechanical isobaric-isothermal (NpT) ensemble. This generalized algorithm, unlike Nose's original NpT algorithm, maintains rigor in the presence of (i) a non-zero system momentum and (ii) non-negligible external forces. The generalized algorithm reduces to the conventional Nose NpT algorithm when neither condition is satisfied. The key element of the generalized algorithm is that the thermostat and barostat are applied only to those degrees of freedom that contribute to the temperature and pressure, which excludes, e.g. the total system momentum. We show that the generalized algorithm satisfies the two criteria for rigor (Hamiltonian and non-Hamiltonian) that exist in the literature. Finally, we provide some numerical examples demonstrating the success of the generalized algorithm.