People were hijacking this question and instead of providing answers they just posted complains about not providing sample code. I ended up finding the solution myself so I want to share it in case somebody is facing the same issues:
In my specific case I have both PHP and plain HTML (Angular) files serving in separate folders but under the same user/domain. The default config works correctly for PHP files but once I visited the folder /app where I have the Angular 8 app running I was getting a 502 error. To solve it I added the following to the default config file:
location /app/ {
root /home/YOURUSER/public_html/app/;
try_files $uri $uri/ /index.html /index.htm /index;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
#Angular seems to have issues if you are not specific about CSS and JS files in headers
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
This seems to work correctly now.