To solve the problem of the low sensitivity of the direct detection of nitrite and nitrate in water using Raman spectroscopy, we propose a three-dimensional composite surface-enhanced Raman spectroscopy (SERS) substrate. In addition, this cysteamine/gold/cysteamine composite structure is self-assembled onto anodic aluminum oxide and has a three-dimensional porous structure. Experimental results determined that the substrate’s detection limits for nitrite and nitrate are 0.1 mg/L and 1 mg/L, respectively. Moreover, these meet environmental groundwater quality class Ⅱ (nitrite, ≤0.1 mg/L) and class Ⅰ (nitrate, ≤1 mg/L), respectively. The relative standard deviations calculated for nitrite and nitrate were 6.19 % and 4.93 %, respectively. Furthermore, the SERS substrate achieved equivalent detection limits for mixed nitrite and nitrate solution compared to separate nitrite and nitrate solutions, albeit with a weaker Raman signal. Therefore, this SERS substrate is capable of the sensitive and rapid determination of nitrite and nitrate at low concentrations without any treatment.