Node.JS reverse proxied with Nginx on diffrent machines

I have an node.js application running on a raspberry pi, within my LAN. But now I would like to access it from the web. I have a nginx server running and serving content through both http and https.

For the https/ssl endpoint I have a simple non wildcard certificate. This restricts me to www.foo.com and foo.com. So I can not do nodeapp.foo.com. So my plan B is making foo.com/nodeapp.

I configured this, and it works fine for the dynamic content, but the static content doesn't load because the urls used in the generated html point to eg. foo.com/js/jquery.js instead of foo.com/nodeapp/js/jquery.js

Can anyone give me pointers on how to set this up. I tried all kinds of stuff (url rewriting in nginx, url rewriting in node.js) but I'm lost.

As I understand your question, you serve static content from your Node app. Better way is to move your static content from your Node app and let Nginx serve the static contents. Simply copy your static content (eg. /js, /css, /images) into your nginx www directory. In your case you will get also much better performance and you will save your raspberry resources. If it will interfere with your existing www content, move them to extra directory (eg. /assets/js, /assets/css, ...) and change your html accordingly.