We present a simple, accurate method for computing singular or nearly singular integrals on a smooth, closed surface, such as layer potentials for harmonic functions evaluated at points on or near the surface. The integral is computed with a regularized kernel and corrections are added for regularization and discretization, which are found from analysis near the singular point. The surface integrals are computed from a new quadrature rule using surface points which project onto grid points in coordinate planes. The method does not require coordinate charts on the surface or special treatment of the singularity other than the corrections. The accuracy is about O($h^3$), where $h$ is the spacing in the background grid, uniformly with respect to the point of evaluation, on or near the surface. Improved accuracy is obtained for points on the surface. The treecode of Duan and Krasny for Ewald summation is used to perform sums. Numerical examples are presented with a variety of surfaces.