Q:

nginx set different document root for a proxypass

I'm just trying to run a nodejs app I made on a proxypass domain, and have it work exactly as it did on my desktop. However, for some reason, even though I defined a seperate document root for this proxypass path, it didn't load the files from it. I've done the exact same thing with my 404 page, and it worked. Here's the page in question: https://jakesandbox.com/iwl which does load the server.js file, which in turn loads the index.html file, but all of the scripts and styles the index references cannot be loaded. Here's my nginx config(with censors):
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        root /home/ubuntu/FAKE WEB ROOT DIR;
        index index.html index.htm index.php index.nginx-debian.html;
        server_name XXxXX.com;
        error_page 404 /404.html;
        location = /404.html {
                root /home/ubuntu/FAKE ERROR DIR/;
                internal;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        }
        location ~ /\.ht {
                deny all;
        }
        ssl_certificate /etc/letsencrypt/live/XXxXX.com.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/XXxXX.com.com/privkey.pem;
        location /iwl {
                root /home/ubuntu/FAKE NODEJS DIR/;
                proxy_pass http://localhost:PORT/;
                proxy_ssl_trusted_certificate /etc/letsencrypt/live/XXxXX.com.com/fullchain.pem;
                proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        }
}

P.S. I'm not willing to relocate my nodejs app to my webroot/change paths

A:

If you open up the Network tab on your browser's devtools, you can see that the site is trying to load the assets at the root of the URL.  for example:
https://jakesandbox.com/style.css 404

As you don't wish to change the Node.JS paths, you could get around this with an nginx location wildcard, added to the server block:
location ~* \.(js|css)$ {
        root /path/to/your/node/root;   
        expires 30d;
    }

You may need to edit this to include other extensions.  I'ved included js and css above.
/path/to/your/node/root should contain the css and js files at that level.
EDIT
I"m running out of time to test this, but yes the location block I posted may catch JS, CSS files at the root of the domain.  Can you test and update the comments.  This rule may work better:
location ~* ^/iwl/.+\.(js|css|jpg)$ {
    root /path/to/your/node/root;
} 

However I"m having trouble with this myself, as when applied appears to look for /path/to/your/node/root/iwl/style.css meaning you'd have to move anything in your node root to a subdirectory called iwl.  If you can afford to make this change then it might be benificial.  You could even call the directory static which is the common method used for other frontend sites.

