1

我有一个如下所示的 nginx 配置:

location /textproxy {
  proxy_pass http://$arg_url;
  proxy_connect_timeout 1s;
  proxy_redirect off;
  proxy_hide_header Content-Type;
  proxy_hide_header Content-Disposition;
  add_header Content-Type "text/plain";
  proxy_set_header Host $host;
}

这个想法是,这代理到远程 url,并将内容标题重写为 text/plain。

例如我会打电话:

http://nx/textproxy?url=http://foo:50070/a/b/c?arg=abc:123

它会返回 的内容http://foo:50070/a/b/c?arg=abc:123,但用 text/plain header 包裹。

但这似乎不起作用,我经常收到“无效的上游端口”错误:

2013/07/23 19:05:10 [error] 25292#0: *963177 invalid port in upstream "http://foo:50070/a/b/c?arg=abc:123", client: xx.xxx.xx.xx, server: ~^(?<h>nx)(\..+|)$, request: "GET /textproxy?url=http://foo:50070/a/b/c?arg=abc:123 HTTP/1.1", host: "nx"

有任何想法吗?我很难解决这个问题。

4

0 回答 0