Perspective & nginx - Sign out & 502 Bad Gateway

Kind of hoping someone else using nginx and Perspective has encountered this and found a solution. We are using nginx for both SSL and rewrite. While that does work, the issue is when I go to sign out nginx gives me “502 Bad Gateway” error. Worse if I hit enter in the address bar I will be redirected back to the login where I need to sign in again. But my credentials appear to be cached so I do not have to re-enter username and password it just logs me back in (kind of defeating purpose of logging out.

My nginx config:

        location /{
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;            
            proxy_set_header Connection "upgrade";
            proxy_pass http://127.0.0.1:8088;
        }
        location /TestProject01{
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://127.0.0.1:8088/data/perspective/client/TestProject01;
    	    rewrite ^/TestProject01$ /data/perspective/client/TestProject01/ permanent;
        }

I tried a rewrite of ‘logout’ with no success, don’t know if I had the correct syntax or not. What I think I need is somehow to have the connection fully closed on sign out plus redirect to the login or portal screen.

Can this be done? Has anyone else encountered this?