0

我们使用 nginx 在 AWS presto 集群前面提供一个安全层。我们为 nginx-presto-cluster.our-domain.com 注册了 SSL 证书

presto 的请求通过具有基本身份验证的 nginx 传递。presto 的 SQL 查询会导致对服务器的多个顺序请求,以获取查询结果。

我们创建了一个如下所示的 nginx.conf:

location / {
  auth_basic $auth;
  auth_basic_user_file /etc/nginx/.htpasswd;
  sub_filter_types *;
  sub_filter_once off;
  sub_filter 'http://localhost:8889/' 'https://presto.nginx-presto-cluster.our-domain.com/';
  proxy_pass http://localhost:8889/;
}

Presto 的响应包含一个 nextUri 来获取结果。sub_filter 将这些 Uri 从 localhost:8889 重写到我们的安全域,在那里它们再次通过 nginx。

问题:第一个响应的主体看起来完全符合预期:

{
  "id":"20171123_104423_00092_u7hmr"
  , ... 
  ,"nextUri":"https://presto.nginx-presto-cluster.our-domain.com/v1/statement/20171123_104423_00092_u7hmr/1"
  , ...
}

然而,第二个请求看起来像:

{
  "id":"20171123_105250_00097_u7hmr"
  , ...
  , "nextUri":"http://localhost:8889/v1/statement/20171123_105250_00097_u7hmr/2"
  , ...
}

我们本来希望重写总是以同样的方式工作。

你能帮助我们吗?

4

1 回答 1

0

我们通过添加解决了这个问题

proxy_set_header Accept-Encoding "";

进入上面的配置片段。

原因是流量可能会在进程中被压缩,如果启用的话。然后,字符串替换将不适用于压缩内容。

通过不接受任何编码,我们可以防止这种压缩。

于 2017-11-29T12:52:07.623 回答