小编apt*_*moo的帖子

从nginx到squid的反向代理

类似,我试图在 nginx 后面托管一个鱿鱼代理:

example.com - 主要站点

relay.example.com - 鱿鱼服务器。

到目前为止,当我尝试使用 squid 代理时,它会抱怨访问非法页面,例如,如果我尝试访问http://www.google.com,我会收到一个 Invalid URL 错误,指出该 URL /http://www.google.com(注意前面的 /)。任何人都可以建议为什么会发生这种情况,或者修复 nginx 或者可能在鱿鱼配置中?

upstream @squid {
    server localhost:3128;
}

server {
    listen 80;
    server_name relay.example.com;

    location / {
        proxy_pass http://@squid/$scheme://$host$uri;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Request-URI $request_uri;

        proxy_redirect off;
    }
}
Run Code Online (Sandbox Code Playgroud)

https://imgur.com/qtgrZI9

鱿鱼的日志给出:

1423083723.857      0 127.0.0.1 NONE/400 3530 GET /http://www.google.com/ - HIER_NONE/- text/html
Run Code Online (Sandbox Code Playgroud)

和 nginx 用于相同的请求:

12.34.56.78 - - [04/Feb/2015:16:02:03 …
Run Code Online (Sandbox Code Playgroud)

proxy reverse-proxy nginx squid http-proxy

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

http-proxy ×1

nginx ×1

proxy ×1

reverse-proxy ×1

squid ×1