In both cases, either a buzz on an open string or a back buzz on a depressed string, the cure is to raise the nut. You can make a new nut, you can use bone dust or baking soda with super glue to build up the string height in the nut slot, or you can shim the nut from below. The most elegant cure is a new nut. Another common problem is fret misalignment. The frets should be placed in a generally consistent plane, If one fret is to high the misalignment can cause the string to come into contact with that fret when playing the note one half step below.
Fret noise is a funny thing.
I have seen guitars where the frets were perfectly aligned, and still there was noise as if the frets where out of alignment from one end of the board to the other. Because the problem of string height over a fret is directly related to the diameter of the string's oscillation, the height of the strings required for noise-free playing can change, given the guitar's scale length and its top stiffness. I had a classical guitar made by a notable maker in my shop once that would not stop buzzing. The frets were accurately aligned, and still it buzzed. This guitar was very lively and had great oscillation of its strings.