【问题标题】:Migrate to istio/envoy from nginx with sub_filter使用 sub_filter 从 nginx 迁移到 istio/envoy
【发布时间】:2020-08-25 00:47:15
【问题描述】:

想知道我是否可以将这样的 nginx 配置迁移到 istio。

关于如何在公共负载均衡器上公开 aws 的 vpc elasticsearch 的根本问题陈述。 aws-es 实例使用认知端点进行保护。虽然我可以获得 cognito 重定向工作,但它会构造一个重定向 url,如

https:/mydomain.auth.us-east-1.amazoncognito.com/login?response_type=code&client_id=6rn9ch5reoehhle1gmfgv238k0&redirect_uri=https://vpc-mykibana-111xxx.us-east1.es.amazonaws.com/_plugin/kibana/app/kibana&state=7781cfab-838b-4473-9b7f-3ba2b3238528。此重定向 url 在 cognito 中不可配置,并且可能是开箱即用的 es 配置。

这是来自指南https://aws.amazon.com/premiumsupport/knowledge-center/kibana-outside-vpc-nginx-elasticsearch/

server {
    listen 443;
    server_name $host;

    location ^~ /_plugin/kibana {
        # Forward requests to Kibana -> done using route
        proxy_pass https://vpc-mykibana-111xxx.us-east1.es.amazonaws.com/_plugin/kibana;

        # Handle redirects to Amazon Cognito -> seems working out of box
        proxy_redirect https://mydomain.auth.us-east-1.amazoncognito.com https://$host;

        # Update cookie domain and path
        proxy_cookie_domain vpc-mykibana-111xxx.us-east1.es.amazonaws.com $host;

        proxy_set_header Accept-Encoding "";
        sub_filter_types *;
        sub_filter vpc-mykibana-111xxx.us-east1.es.amazonaws.com $host;  <- main reason why the redirects are not correct for us
        sub_filter_once off;

        # Response buffer settings <- not important
        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
    }

    location ~ \/(log|sign|error|fav|forgot|change|confirm) {
        # Forward requests to Cognito
        proxy_pass https://mydomain.auth.us-east-1.amazoncognito.com;

        # Handle redirects to Kibana
        proxy_redirect https://vpc-mykibana-111xxx.us-east1.es.amazonaws.com https://$host;

        # Handle redirects to Amazon Cognito
        proxy_redirect https://mydomain.auth.us-east-1.amazoncognito.com https://$host;

        # Update cookie domain
        proxy_cookie_domain mydomain.auth.us-east-1.amazoncognito.com $host;
    }
}

尝试了简单的虚拟服务,但不知道下一步如何移动

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: siem-route
  namespace: siem
spec:
  hosts:
    - siem.jupiter.money
  gateways:
    - istio-system/http-gateway
  http:
    - match:
      - uri:
          match: /_plugin/kibana
      route:
        - destination:
            host: vpc-mykibana-111xxx.us-east1.es.amazonaws.com

【问题讨论】:

  • 为什么不合并它们呢?例如here。使用您的配置创建注入的 nginx pod,然后以这个注入的 nginx pod 作为主机创建虚拟服务?
  • 嘿,你设法让它工作了吗?

标签: amazon-web-services amazon-cognito istio envoyproxy amazon-elasticsearch


【解决方案1】:

想知道我是否可以将这样的 nginx 配置迁移到 istio。

正如我在 cmets 中提到的,您应该将它们一起使用,在虚拟服务中无法执行 proxy_pass 之类的操作。

如上所述here

不应该让ISTIO做反向代理吗 事情,所以没有人需要一个网络服务器(httpd/nginx/ lighthttpd/...) 做反向代理工作?

还有答案。

Istio 控制平面的工作是配置一组反向代理。网络服务器的目的是提供内容,而不是反向代理。 Istio 的核心反向代理技术是 Envoy,Envoy 可以用作 HAProxy、nginx、Apache、F5 或任何其他用作反向代理的组件的替代品。


相反,您可以使用您的配置创建 nginx pod,并使用 nginx 作为路由主机创建虚拟服务。

所以它看起来像下面的例子。

示例

ingress gateway -> gateway -> Virtual Service -> nginx(在 nginx 上配置反向代理和其他东西)-> kibana,cognito

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: test
spec:
  hosts:
    - siem.jupiter.money
  gateways:
    - gateway_test
  http:
    - match:
      - uri:
          match: /_plugin/kibana
      route:
        - destination:
            host: nginx.default.svc.cluster.local

【讨论】:

  • 感谢您的回答。我正在更多地研究如何使用 envoyfilter 来做同样的事情。 Istio 有一个 crd 来注入一个 envoy 过滤器。类似github.com/envoyproxy/envoy/issues/9170
猜你喜欢
  • 2014-02-17
  • 2021-04-30
  • 2014-05-28
  • 1970-01-01
  • 1970-01-01
  • 2014-06-04
  • 2020-06-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多