Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can squid run behind nginx?

Tags:

nginx

squid

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?

like image 280
kkpattern Avatar asked Nov 14 '22 03:11

kkpattern


1 Answers

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; }

like image 93
shrikeh Avatar answered Feb 07 '23 19:02

shrikeh