Can squid run behind nginx?

耗尽温柔 提交于 2019-12-03 13:38:44

问题


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?


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



来源:https://stackoverflow.com/questions/11029129/can-squid-run-behind-nginx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!