gpt4 book ai didi

nginx - 如何在Nginx Ingress中对特定的HTTP方法进行基本身份验证?

转载 作者:行者123 更新时间:2023-12-02 11:48:31 25 4
gpt4 key购买 nike

我可以使用基本身份验证创建入口。我遵循了来自kubernetes / ingress-nginx的模板:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-with-auth
annotations:
# type of authentication
nginx.ingress.kubernetes.io/auth-type: basic
# name of the secret that contains the user/password definitions
nginx.ingress.kubernetes.io/auth-secret: basic-auth
# message to display with an appropriate context why the authentication is required
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - foo'
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /
backend:
serviceName: http-svc
servicePort: 80

它工作正常,但是我需要允许“OPTIONS”方法在没有预身份验证的情况下进行飞行前请求。有关如何执行操作的任何指示都将非常有帮助。

最佳答案

您可以启用带有注解的nginx-ingress cors:
nginx.ingress.kubernetes.io/enable-cors: "true"
有关更多配置,请参见this

关于nginx - 如何在Nginx Ingress中对特定的HTTP方法进行基本身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51988839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com