Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include the original url as a request parameter, when proxying?

Tags:

nginx

proxy

I want to proxy the incoming requests with an nginx instance to a little java backend application. The idea is that I want every original request's uri to be included as a request parameter i.e. something like:

location / {
            proxy_pass http://localhost:9000?url=$request_uri;
        }

but it does not work

like image 808
Preslav Rachev Avatar asked Apr 24 '13 09:04

Preslav Rachev


1 Answers

location / {
            proxy_pass http://localhost:9000$request_uri;
        }

The @request_uri is equal to the original request URI as received from the client including the args.

The $request_uri of this post is /questions/16188521/how-do-i-include-the-original-url-as-a-request-parameter-when-proxying.

see http://wiki.nginx.org/HttpCoreModule#.24request_uri

like image 67
hailinzeng Avatar answered Sep 22 '22 22:09

hailinzeng