小编Ant*_*ton的帖子

在 nginx proxy_pass 中禁用 IPv6

我的服务器没有 IPv6 地址。

但是,当我使用 Nginx proxy_pass 使用 IPv4 和 IPv6 到上游时,有时它会尝试使用 IPv6 发送传出请求:

2013/07/30 00:25:06 [error] 1930#0: *1482670 connect() to [AAAA:BBBB:C:DDD:E:F:GGG:HHH]:443 failed (101: Network is unreachable) while connecting to upstream, client: AA.BB.CC.DD, server: example.com, request: "GET /download/file HTTP/1.0", upstream: "https://[AAAA:BBBB:C:DDD:E:F:GGG:HHH]:443/download/file", host: "example.com"
Run Code Online (Sandbox Code Playgroud)

如何在 proxy_pass 中为传出请求禁用 IPv6?

nginx.conf:

upstream download {
  server download.example.com:443;
  keepalive 8;
}

location /download {
  proxy_set_header      X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_set_header      Connection "";
  proxy_ignore_headers  X-Accel-Redirect;
  proxy_http_version    1.1;
  resolver              8.8.8.8;
  resolver_timeout      5s;
  proxy_pass            https://download;
}
Run Code Online (Sandbox Code Playgroud)

nginx -V:

nginx version: nginx/1.4.2 …
Run Code Online (Sandbox Code Playgroud)

nginx

27
推荐指数
2
解决办法
4万
查看次数

标签 统计

nginx ×1