你应该遵循哪个入口文档?如何应用nginx.conf?

huangapple go评论117阅读模式
英文:

Which ingress documentation to follow? and how to apply nginx.conf?

问题

你可以使用已经工作的nginx.conf吗?可以为nginx.conf创建一个configMap。如何将configMap应用到以下ingress中?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
spec:
  tls:
    - hosts:
        - "*.mydomin.com"
      secretName: mydomain-ssl
  rules:
    - host: "*.mydomain.com"
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: my-webapp
                port:
                  number: 8080
英文:

https://kubernetes.github.io/ingress-nginx/

or

https://docs.nginx.com/nginx-ingress-controller/

Can I just use nginx.conf that is already working? A configMap can be created for the nginx.conf. How to apply the configMap to the following ingress?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
      
spec:

  tls:
    - hosts:
        - "*.mydomin.com"
      secretName:mydomain-ssl

  rules:
    - host: "*.mydomain.com"
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: my-webapp
                port:
                  number: 8080

答案1

得分: 1

要创建一个使用nginx.conf的配置映射,请参考Google官方文档链接

创建配置映射后,您可以使用annotation "snippets"将其应用于入口,您可以在下面找到示例yaml,并且要获取更多信息,您可以参考NGINX的文档

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: cafe-ingress-with-annotations
 annotations:
   nginx.org/proxy-connect-timeout: "30s"
   nginx.org/proxy-read-timeout: "20s"
   nginx.org/client-max-body-size: "4m"
   nginx.org/server-snippets: |
     location / {
       return 302 /coffee;
     }      
spec:
英文:

To create a config map using the nginx.conf refer to this official Google document.

After creating a config map you can use annotation “snippets” to apply it to the ingress, you can find the sample yaml below and For more information you can follow this NGINX documentation.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: cafe-ingress-with-annotations
 annotations:
   nginx.org/proxy-connect-timeout: "30s"
   nginx.org/proxy-read-timeout: "20s"
   nginx.org/client-max-body-size: "4m"
   nginx.org/server-snippets: |
     location / {
       return 302 /coffee;
     }      
spec:

huangapple
  • 本文由 发表于 2023年8月9日 14:33:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76865146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定