gpt4 book ai didi

Kubernetes Ingress header 单引号

转载 作者:行者123 更新时间:2023-12-05 04:36:39 41 4
gpt4 key购买 nike

我遇到了一个非常奇怪的问题,我无法设置 Content-Security-Policy 所需的单引号。我假设我运行的是旧版本的 ingress,它仅在我禁用并重新启用它 (microk8s) 后才得到更新。

    nginx.ingress.kubernetes.io/configuration-snippet: |
add_header Access-Control-Allow-Origin "https://myhost";
more_set_headers "X-FRAME-OPTIONS: SAMEORIGIN";
more_set_headers "Content-Security-Policy: default-src 'self' blob:;";

结果:

skipping ingress ...: nginx.ingress.kubernetes.io/configuration-snippet annotation contains invalid word '

我尝试过使用 x2,使用 \ 转义,用单引号将所有内容括起来并转义,但没有任何效果。如果有人能告诉我如何在标题中添加单引号,或者我是否可以避免它们并仍然发送 CSP,我将不胜感激。

编辑:需要说明的是,此配置过去适用于旧版本,现在入口版本为 v1.0.5。语法或其他设置都没有问题。

最佳答案

变化恰好出现在1.0.5中与清理注释输入相关。

您可能需要查看 CVE-2021-25742: Ingress-nginx custom snippets .我在粗体中输入了您感兴趣的部分。

annotation-value-word-blocklist defaults are"load_module,lua_package,_by_lua,location,root,proxy_pass,serviceaccount,{,},',"

Users from mod_security and other features should be aware that someblocked values may be used by those features and must be manuallyunblocked by the Ingress Administrator.

在我看来,您的问题与 mod_security + above blocklist 相关,其中包含 ' 符号。

更多详情请查看https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#annotation-value-word-blocklist

为了解决您的问题,您应该

  • 设置annotation-value-word-blocklist的值为空字符串""

  • 更改 annotation-value-word-blocklist 的值并从其列表中删除 '

关于Kubernetes Ingress header 单引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70785021/

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