如何在 nginx ingress 上添加自定义安全策略和 referrer 策略

how to add custom security policy and referrer policy on nginx ingress

我只是尝试使用配置片段注释但没有用

nginx.ingress.kubernetes.io/configuration-snippet: |
  more_set_headers "Content-Security-Policy: script-src 'self'";
  more_set_headers "Referrer-Policy: 'same-origin';"
  more_set_headers "Feature-Policy: "geolocation 'none'; vibrate 'none';";"

还有其他方法吗? 我的 nginx 控制器版本是 nginx-ingress:1.8.1 和 运行 on gcp

Nginx Ingress Controller 有自己的方式为上游服务器定义custom http headers

您尝试使用的方法需要为 nginx 安装额外的 thrid-party 模块。此模块未打包到 base image of the Controller.