nginx修改网址的标题

时间:2018-12-06 05:55:41

标签: nginx squid

我已经配置了nginx,服务器名称为t0.t1.t2,端口为80,并且我正在将代理传递到IP地址为xxx0和端口3128的鱿鱼代理,当我连接到服务器名称为t0.t1.t2的代理时端口80。请求到达了squid,但显示的是无效网址的页面。

当我检查时,发现浏览器正在发送正确的标头,但是nginx正在修改标头并发送到squid。这就是鱿鱼显示无效网址的原因。

以下是我的nginx配置:

server {
    listen 80;
    server_name t0.t1.t2;

    location / {
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_pass http://app;
            proxy_redirect off;
            proxy_ignore_headers "Cache-Control" "Expires";
    }

}

upstream app {
    server 127.0.0.1:3128;
}

以下是nginx调试日志:

2018/12/06 07:10:41 [debug] 4007#4007: accept on 0.0.0.0:80, ready: 1
2018/12/06 07:10:41 [debug] 4007#4007: posix_memalign: 00005613FC643650:512 @16
2018/12/06 07:10:41 [debug] 4007#4007: *1 event timer add: 3: 60000:1544080301995
2018/12/06 07:10:41 [debug] 4007#4007: *1 reusable connection: 1
2018/12/06 07:10:41 [debug] 4007#4007: *1 epoll add event: fd:3 op:1 ev:80002001
2018/12/06 07:10:41 [debug] 4007#4007: accept() not ready (11: Resource temporarily unavailable)
2018/12/06 07:10:41 [debug] 4007#4007: *1 http wait request handler
2018/12/06 07:10:41 [debug] 4007#4007: *1 malloc: 00005613FC675210:1024
2018/12/06 07:10:41 [debug] 4007#4007: *1 recv: fd:3 345 of 1024
2018/12/06 07:10:41 [debug] 4007#4007: *1 reusable connection: 0
2018/12/06 07:10:41 [debug] 4007#4007: *1 posix_memalign: 00005613FC654FA0:4096 @16
2018/12/06 07:10:41 [debug] 4007#4007: *1 http process request line
2018/12/06 07:10:41 [debug] 4007#4007: *1 http request line: "GET / HTTP/1.1"
2018/12/06 07:10:41 [debug] 4007#4007: *1 http uri: "/"
2018/12/06 07:10:41 [debug] 4007#4007: *1 http args: ""
2018/12/06 07:10:41 [debug] 4007#4007: *1 http exten: ""
2018/12/06 07:10:41 [debug] 4007#4007: *1 http process request header line
2018/12/06 07:10:41 [debug] 4007#4007: *1 http header: "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0"
2018/12/06 07:10:41 [debug] 4007#4007: *1 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2018/12/06 07:10:41 [debug] 4007#4007: *1 http header: "Accept-Language: en-US,en;q=0.5"
2018/12/06 07:10:41 [debug] 4007#4007: *1 http header: "Accept-Encoding: gzip, deflate"
2018/12/06 07:10:41 [debug] 4007#4007: *1 http header: "Upgrade-Insecure-Requests: 1"

如您在http uri中看到的,显示为“ /”。

我需要在nginx配置中进行哪些更改,通过该配置我可以配置nginx以直接传递浏览器发送到squid的标头?

0 个答案:

没有答案