Can squid run behind nginx?

2020-05-28 11:23发布

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?

标签: nginx squid
1条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-05-28 11:45

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

查看更多
登录 后发表回答