We develop a nonlocal-response generalization to the Green's function surface-integral method (GSIM), also known as the boundary-element method. This numerically efficient method can accurately describe the linear hydrodynamic nonlocal response of arbitrarily shaped plasmonic nanowires in arbitrary dielectric backgrounds. All previous general-purpose methods for nonlocal response are bulk methods. We also expand the possible geometries to which the usual local-response GSIM can be applied, by showing how to regularize singularities that occur in the surface integrals when the nanoparticles touch a dielectric substrate. The same regularization works for nonlocal response. Furthermore, an effective theory is developed to explain the numerically observed nonlocal effects. The nonlocal frequency blueshift of a cylindrical nanowire in an inhomogeneous background generally increases as the nanowire radius and the longitudinal wave number become smaller, or when the effective background permittivity or the mode inhomogeneity increase. The inhomogeneity can be expressed in terms of an effective angular momentum of the surface-plasmon mode. We compare local and nonlocal response of freestanding nanowires, and of nanowires close to and on top of planar dielectric substrates. Especially for the latter geometry, considerable differences in extinction cross sections are found for local as compared to nonlocal response, similar to what is found for plasmonic dimer structures.