Welcome! Log In Create A New Profile

Advanced

Rewrite inside location block before proxy to local port

March 05, 2013 07:00AM
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!
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewrite inside location block before proxy to local port

jwxie March 05, 2013 07:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready