鱿鱼可以在nginx之后运行吗? [英] Can squid run behind nginx?
问题描述
我正在尝试在nginx后面运行一个鱿鱼服务器. 我这样配置nginx:
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;
}
}
然后将我的http网络代理设置为:
Then I set my http network proxy to:
my-nginx-server-address:8080
因此,当我尝试查看Google主页时,nginx将收到请求:
So when I try to view the Google homepage, the nginx will get the request:
Get http://www.google.com/ HTTP/1.1
但是,当nginx将请求传递给squid时,它将把request_uri更改为
However when nginx pass the request to squid it will change the request_uri to
/
所以鱿鱼不起作用. 有什么办法可以将request_uri设置回 http://www.google.com ,然后将其传递给鱿鱼?或者我可以在nginx后面运行乌贼的任何其他方式?
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?
推荐答案
尝试使用proxy_set_header Request-URI $ request_uri;
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;
}
upstream _squid {
server localhost:3128;
}
server {
...
proxy_pass http://_squid/$host$uri;
}
这篇关于鱿鱼可以在nginx之后运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!