I fixed it!
Following up on the one error message I had, I eventually stumbled upon https://www.cyberciti.biz/faq/nginx-upstream-sent-too-big-header-while-reading-response-header-from-upstream.
First I tried just adding to the (HTTPS) server block corresponding to my Nexcloud instance in my nginx
config:
proxy_busy_buffers_size 512k;
proxy_buffers 4 512k;
proxy_buffer_size 256k;
This alone did not do the trick as I could still reproduce the error by visiting the root URL of my instance (after restarting the webserver, of course).
However, after I also added
fastcgi_buffers 16 32k;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 64k;
and restarted the webserver again, the error message and the 502 responses dissappeared. My existing devices started syncing again and adding my new device worked as expected.
@artlog1: Thank you for your support in debugging this.
What would be the right place to suggest adding these options to the recommended nginx
configuration in the Nextcloud documentation?