5

I'm trying to run a squid server behind nginx. I configured nginx like this:

server {
    listen     8080;
    location / {
        proxy_pass   http://localhost:3128;
        proxy_set_header Host  $host;
        proxy_set_header X-Real-IP   $remote_addr;
    }
}

Then I set my http network proxy to:

my-nginx-server-address:8080

So when I try to view the Google homepage, the nginx will get the request:

Get http://www.google.com/ HTTP/1.1

However when nginx pass the request to squid it will change the request_uri to

/

So squid won't work. Is there any way I can set the request_uri back to http://www.google.com then pass it to squid? Or any other ways I can run squid behind nginx?

kkpattern
  • 948
  • 2
  • 7
  • 31

1 Answers1

1

Try proxy_set_header Request-URI $request_uri;

In reply to your comment, you may also prefer to add:

upstream _squid { server localhost:3128; } server { ... proxy_pass http://_squid/$host$uri; }

shrikeh
  • 661
  • 9
  • 12
  • I tried this myself and I couldn't figure out how to get squid to pay attention to this Request-URI header. Maybe this is something not supported in the latest version of squid? I can't even find any documentation mentioning this header. – Dobes Vandermeer Sep 04 '14 at 05:58