Can squid run for nginx?

I am trying to start a squid server for nginx. I configured nginx as follows:

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

Then I installed my http network proxy:

my-nginx-server-address:8080

Therefore, when I try to view the Google homepage, nginx will receive a request:

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

However, when nginx passes the request to squid, it will change request_uri to

/

So the squid will not work. Is there a way to return request_uri to http://www.google.com and then pass it to the squid? Or in any other way I can run squid for nginx?

+5
source share
1 answer

Try proxy_set_header Request-URI $ request_uri;

In response to your comment, you can also add:

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

+1
source

All Articles