Rewrite inside location block before proxy to local port

Hi,

I asked somewhat releated question here:
http://serverfault.com/questions/484573/nginx-proxy-to-a-new-vm-without-affect-old-site-enabled-rules

Problem arises with one java program. This java program now expects
/beta/scm because it said “/scm not found” in its pretty java error
page.
Not nginx 404.

So this is what I have

server {
rewrite ^/beta(.*)$ $1 last; # strip out the beta

location /scm {
    proxy_pass http://localhost:8080;
    proxy_redirect default;
    #proxy_set_header Host $http_host;
    #proxy_set_header X-Real-IP $remote_addr;
    #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

So I am guessing, internally, when we proxy to 8080, the web app
actually
receives /scm. That makes sense.

Can we rewrite the url back to /beta/scm inside the location?
I tried this rewrite ^/scm(.*)$ /beta/scm last;

not working at all. Ngninx would throw 404

access
10.10.0.57 - - [05/Mar/2013:06:55:29 -0500] “GET /beta/scm/ HTTP/1.0”
404
570 “-” “Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.22 (KHTML, like
Gecko) Chrome/25.0.1364.97 Safari/537.22”

error
2013/03/05 06:55:29 [error] 14867#0: *1
“/usr/share/nginx/html/beta/scm/index.html” is not found (2: No such
file
or directory), client: 10.10.0.57, server: localhost, request: “GET
/beta/scm/ HTTP/1.0”, host: “134.74.77.21”

Why we are looking at /usr/share…/index.html/ ?

Any idea how to resolve this issue?

Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs