简体   繁体   English

如何使用 Nginx 入口 controller 为对讲机设置 SSL?

[英]How to setup SSL for Intercom using Nginx ingress controller?

I'm trying to enable https for custom domain for Intercom setup.我正在尝试为自定义域启用https以进行对讲设置。 The documentation tells:文档告诉:

server {
  listen 443 ssl;
  server_name your-help-site.custom-domain.com; # replace this with your domain

  ssl_certificate /path/to/your/fullchain.pem;
  ssl_certificate_key /path/to/your/privatekey.pem;

  location / {
    # using "set" is important as IP addresses of Intercom servers 
    # changes dynamically. "set" enables nginx to follow dynamic IPs
    set $intercom "https://custom.intercom.help:443"; 
    proxy_set_header Host $host;
    proxy_pass $intercom;
  }
}

I've tried this approach:我试过这种方法:

resource kubernetes_ingress help_ingress {
  metadata {
    name = "help-ingress"
    annotations = {
      "certmanager.k8s.io/cluster-issuer"              = "letsencrypt-prod"
      "kubernetes.io/ingress.class"                    = "nginx"
      "nginx.ingress.kubernetes.io/permanent-redirect" = "http://custom.intercom.help"
      "nginx.ingress.kubernetes.io/rewrite-target" = "/"
      "ingress.kubernetes.io/force-ssl-redirect"         = false
      "nginx.ingress.kubernetes.io/from-to-www-redirect" = true
    }
  }
  spec {
    tls {
      secret_name = "help-cert"
      hosts       = [local.help_url, "www.${local.help_url}"]
    }
    rule {
      host = "${local.help_url}"
      http {
        path {
          path = ""
          backend {
            service_name = "fake"
            service_port = 80
          }
        }
      }
    }
  }
}

But it gives me just a redirect to https://custom.intercom.help How to achieve that proxy_path using k8s nginx ingress ?但它只给了我一个重定向到https://custom.intercom.help proxy_path使用k8s nginx ingress实现该代理路径?

I faced the same issue and found a solution that works for me.我遇到了同样的问题,并找到了适合我的解决方案。

Of course you need to first configure your custom domain in the intercom settings here: https://app.intercom.io/a/apps/_/articles/site/settings当然你需要先在此处的对讲设置中配置你的自定义域: https://app.intercom.io/a/apps/_/articles/site/settings

Then you need to create a "CNAME" service in your cluster like so:然后您需要在集群中创建一个“CNAME”服务,如下所示:

kind: Service
apiVersion: v1
metadata:
  name: intercom-service
  namespace: ingress-nginx
spec:
  type: ExternalName
  externalName: custom.intercom.help

Now you can link your ingress to this service and everything should work:现在您可以将您的入口链接到此服务,并且一切都应该正常工作:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: intercom-ingress
  namespace: ingress-nginx
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
    - secretName: tls-intercom-secret
      hosts:
        - **replace.with.domain.com**
  rules:
    - host: **replace.with.domain.com**
      http:
        paths:
          - path: /
            backend:
              serviceName: intercom-service
              servicePort: 80

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NGINX 入口控制器、SSL 和 optional_no_ca - NGINX Ingress controller, SSL and optional_no_ca 无法 SSL 通过入口 Nginx Controller - Unable to SSL Pass through Ingress Nginx Controller Kubernetes 内部 nginx 入口 controller 带 ZEA52C36203C5F99C22CE2442Dssl-ZB1 端接 - Kubernetes internal nginx ingress controller with SSL termination & ssl-passthrough Kubernetes nginx 入口 ssl - Kubernetes nginx ingress ssl Openshift 上的 SSL/TLS 直通 NGINX-Ingress-Controller 不工作 - SSL/TLS passthrough NGINX-Ingress-Controller on Openshift Not Working 在NGINX-Ingress上将会话关联性(Cookies)与SSL传递一起使用 - Using Session Affinity (Cookies) with SSL Passthrough on NGINX-Ingress 如何在AWS和SSL终止中设置kubernetes NGINX ingress - How to set up kubernetes NGINX ingress in AWS and SSL termination 通过 Nginx Ingress 控制器和证书管理器启用 SSL 后 200+ 毫秒创建了 TTFB - TTFB increated by 200+ ms after enabling SSL via Nginx Ingress controller & cert-manager 允许单个入口运行HTTP,而无需使用Traefik Ingress Controller强制使用SSL - Allow single ingress to run HTTP without forcing SSL using Traefik Ingress Controller 入口nginx数字海洋上的ssl终止 - ssl termination on ingress nginx digital ocean
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM