The optical density function is calculated in a single quantum well for two-dimensional excitons moving in a random potential in the interfacial plane generated by fluctuations of the quantum-well thickness. Assuming Gaussian statistics for the random potential distribution, we have applied the path-integral approach and obtained in the adiabatic approximation two asymptotic analytical expressions for the low- and high-energy tails of the optical absorption spectrum. The high-energy tail of the exciton absorption line is also calculated using the perturbation theory. In order to obtain the spectrum across the whole energy range an analytical interpolation formula is found between the asymptotic expressions in the two cases, taking into account the proper normalization of the spectral function. The calculated optical density function is asymmetrically broadened, the magnitude of the peak is reduced, and the maximum is shifted to lower energy in both cases considered, as the disorder increases, in agreement with other theoretical results. Using the fitting parameters to the time-resolved photoluminescence data of Zimmermann [Nuovo Cimento D 17, 1801 (1995)], we find that the path-integral method leads to results for the spectral widths (full widths at half maximum) that are closer to those experimentally observable, as compared with results inferred from the perturbation theory approach. This can be attributed to the additional contribution of the localized exciton states from the Kane band tail in the former method. The effect of varying the correlation length (at a fixed depth of the random potential fluctuations) on the optical density function is also studied.