2

I feel like I must be missing something obvious... but here goes.

Question

Is it possible to configure an Nginx proxy such that it does not modify the HTTP request URI? How?

Background

I have an Nginx reverse proxy (A) in front of a forward proxy (B).

The configuration at A is a plain vanilla reverse proxy setup that looks something like this:

upstream upstreamproxy {
  server 192.168.0.69:80;
}

location / {
  proxy_set_header Host $http_host;
  proxy_pass http://upstreamproxy;
  proxy_redirect off;
  proxy_buffering off;
}

The forward proxy B is also plain vanilla, so it's expecting to see proxy requests like this:

GET http://www.example.com/foo HTTP/1.1
User-Agent: curl/7.30.0
Host: www.example.com
Accept: */*
Proxy-Connection: Keep-Alive

The problem is, reverse proxy A rewrites the HTTP request URI as shown:

Issue an example request:

my-client$ curl --proxy http://<proxy-A IP address>:80 http://www.example.com/foo

Look at what Proxy A is doing:

proxy-A$ ngrep -W byline tcp and port 80

####
T <my-client IP address>:38038 -> <proxy-A IP address>:80 [AP]
GET http://www.example.com/foo HTTP/1.1.
User-Agent: curl/7.30.0.
Host: www.example.com.
Accept: */*.
Proxy-Connection: Keep-Alive.
.

#####
T <proxy-A IP address>:57211 -> 192.168.0.69:80 [AP]
GET /foo HTTP/1.0.
Host: www.example.com.
Connection: close.
User-Agent: curl/7.30.0.
Accept: */*.
Proxy-Connection: Keep-Alive.

Note that the request URI was rewritten from http://www.example.com/foo to /foo. That's what I'm trying to avoid.

FWIW, I've tried fiddling around with the uri portion of the proxy_pass URL without success.

1
  • this sounds like an edge case, which i'm not sure anyone has cared about yet at nginx -- so, unless they did, and changing proxy_http_version to 1.1 does fix the job, i'm afraid you're out of luck.
    – cnst
    Jan 22, 2014 at 0:01

1 Answer 1

1

Maybe you should change proxy_http_version to 1.1. I saw your concern about the path but I think the http version is going to be much more relevant overall.

Best of luck.

1
  • Thank you. I agree. It doesn't solve the issue but you raise a good point.
    – kkurian
    Jan 22, 2014 at 4:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .