Dr Paul Leyland

APT has a variety of sky background models. You might find one that works well in this situation.

APT is the workhorse of my photometry though I’ve never used it where the “sky” varies that much on such a small scale. It appears to work fine where the background gradient is relatively small, such as variables in M31 and M33.

Otherwise I would suggest PSF-fitting photometry such as IRAF/DAOPHOT. Again I’ve never used it in such extreme circumstances but the documentation has reassuring words about what to do where a star is positioned within nebulosity. Be warned: this package has a steep learning curve and is generally labour intensive.