So in this case usually advised to ad the buffer site. It will look like:
server {
listen 80;
server_name host.tld;
location / {
proxy_pass http://upstream;
...
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}
For the mentioned error in your log, this is the first fix.
I observed that if user is logged out of site the changing of templates works, however if user logs in, switching of templates don't work. They still receive 502 gateway error, any idea?
What info in log do you have on these cases?