Nested algebraic Bethe ansatz for orthogonal and symplectic open spin chains