hmm, so adding '^~' to the front of location /foo/bar/ makes "internal" directive work correctly. All direct access to "/foo/bar/sth/sth.html" are blocked with 404 now.
However, the proxy_pass inside '/foo/bar/' location still doesn't work. I even put debugging echo inside all the location blocks, and only the /foo/bar one appears in the log file. But there is still no request proxied to the other server. In the debugging log, I see:
2012/10/18 18:27:57 [debug] 6983#0: *3 http script if
2012/10/18 18:27:57 [debug] 6983#0: *3 http script if: false
2012/10/18 18:27:57 [debug] 6983#0: *3 test location: "/game/play/"
2012/10/18 18:27:57 [debug] 6983#0: *3 http finalize request: 404, "/foo/bar/test-sth?" a:1, c:1
2012/10/18 18:27:57 [debug] 6983#0: *3 http special response: 404, "/foo/bar/test-sth?"
2012/10/18 18:27:57 [debug] 6983#0: *3 internal redirect: "/404.html?"
2012/10/18 18:27:57 [debug] 6983#0: *3 rewrite phase: 1
Then I get 404 in the requesting browser obviously. Any other guess?