sorry for having you run in circles. I suggest take a step back and deep breath, then do the following:
use the cp templates like @eris suggested. both of them:
- copy them into a name for your app
- leave the tpl as it is (unedited)
- edit the stpl so you change the destination port in the proxy_pass directive to 5000 and maybe add the upgrade and forwardedfor headers next to that etc.
save, apply to your domain, try again