Got it!
The problem was absolutely not related to nginx configuration. I found it when I continued to get 502s even with nginx process down O_o
I've accidentally added two A-records to the DNS-zone with same name but different IPs. Looks like the resulting IP was chosen in semi-round-robin fashion. And when a not configured server was chosen, I've got those 502s.
Whew!… Sorry for disturbing.