Your nginx code is incorrect, for example, because you're effectively losing the extra functionality afforded by http://nginx.org/r/proxy_redirect default value of default.
As per the documentation at http://nginx.org/r/proxy_pass, the correct way would be to map location on the front-end and back-end directly within the proxy_pass, especially if you don't need to be using any variables:
location / {
proxy_pass http://127.0.0.1:8080/ipns/QmdpoFuwY/;
}
Otherwise, back to your question, there is absolutely no reason to have /foo and /foo/ point to the same resource.
In fact, it would be perfectly legal for one to be internally expanded to /foo.html, whereas for the other to /foo/index.html, so, the fact that different results are returned is entirely normal, and doesn't need to be fixed.