【问题标题】:nginx reverse proxy treats request urls differentlynginx 反向代理对请求 url 的处理方式不同
【发布时间】:2018-05-07 07:44:54
【问题描述】:

我们正在使用 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"
  , ...
}

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

你能帮我们吗?

【问题讨论】:

    标签: emr presto nginx-reverse-proxy


    【解决方案1】:

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

    proxy_set_header Accept-Encoding "";
    

    进入上面的配置sn-p。

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

    通过不接受任何编码,我们阻止了这种压缩。

    【讨论】:

      猜你喜欢
      • 2019-06-20
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 2021-07-10
      • 1970-01-01
      • 2022-07-02
      • 2017-02-27
      • 2013-07-16
      相关资源
      最近更新 更多