从nginx到squid的反向代理

时间:2015-02-04 21:29:40

标签: nginx proxy reverse-proxy squid http-proxy

this类似,我正在尝试在nginx后面托管一个squid代理:

example.com - 主要网站

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

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

/http://www.google.com

https://imgur.com/qtgrZI9

来自鱿鱼的日志给出:

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

和nginx的相同请求:

1423083723.857      0 127.0.0.1 NONE/400 3530 GET /http://www.google.com/ - HIER_NONE/- text/html

2 个答案:

答案 0 :(得分:1)

在nginx中:

interface PaginationItemProps extends React.HTMLProps<HTMLDivElement> {
}

const PaginationItem = (props: PaginationItemProps) => {
   return <div>{props.children}</div>;
}

class Pagination extends React.Component<PaginationProps> {
  render() {
    return <div>          
        <PaginationItem>CHILDREN RENDER</PaginationItem>
    </div>
  }
}

in squid:

(\d+)(?=\w*<\/msgText>)

以及修复此https://imgur.com/qtgrZI9错误所需的全部内容

答案 1 :(得分:0)

我有同样的问题,通过将squid设置为以透明模式运行来解决它,如下所示:

http_port 3128 transparent