I know about $_SERVER['HTTP_REFERER'] in PHP, and I believe there is something as simple as that in Nitrogen, but I just can't find it in documentation.
You're looking for wf:header(referer), I think.
wf:header(referer)