The a posteriori Fourier method for solving ill-posed problems