apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: gateway
  namespace: mo2
  annotations:
    kubernetes.io/ingress.class: "nginx"
    # 开启use-regex，启用path的正则匹配 
    nginx.ingress.kubernetes.io/use-regex: "true"
    kubernetes.io/tls-acme: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    # ratelimit
    nginx.ingress.kubernetes.io/limit-connections: "60"
    nginx.ingress.kubernetes.io/limit-rps: "60"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.org/websocket-services: yjs
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto https;
spec:
  rules:
    - host: www.motwo.cn
      http:
        paths:
        # 不同path转发到不同端口
          - path: /yjs
            pathType: Prefix
            backend:
              service: 
                name: yjs
                port: 
                  number: 1234
          - path: /api
            pathType: Prefix
            backend:
              service: 
                name: mo2
                port: 
                  number: 5001
          - path: /
            pathType: Prefix
            backend:
              service:
                name: mo2front
                port:
                  number: 8110
    - host: kshub.pivotstudio.cn
      http:
        paths:
        # 不同path转发到不同端口
          - path: /api
            pathType: Prefix
            backend:
              service: 
                name: mo2
                port: 
                  number: 5001
          - path: /
            pathType: Prefix
            backend:
              service:
                name: mo2front
                port:
                  number: 8110
  tls:
  - secretName: pivot-tls-cert
    hosts:
      - www.motwo.cn
      - kshub.pivotstudio.cn