跳转至

多行响应头

Gixy Check ID: add_header_multiline

应避免使用多行响应头,因为: - 它已被弃用(见 RFC 7230); - 某些 HTTP 客户端和浏览器从未支持(例如 IE/Edge/Nginx)。

如何发现?

错误配置示例:

# https://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header
add_header Content-Security-Policy "
    default-src: 'none';
    script-src data: https://yastatic.net;
    style-src data: https://yastatic.net;
    img-src data: https://yastatic.net;
    font-src data: https://yastatic.net;";

# https://nginx-extras.getpagespeed.com/modules/headers-more/
more_set_headers -t 'text/html text/plain'
    'X-Foo: Bar
        multiline';

如何规避?

唯一的解决方案就是不要使用多行响应头。

加固 NGINX,使用维护的 RPM

使用 GetPageSpeed 提供的 NGINX Extras 在 RHEL/CentOS/Alma/Rocky 上获取持续更新的 NGINX 与模块。 了解更多.