zoukankan      html  css  js  c++  java
  • Nginx不转发http header

    使用nginx做http代理时,在Header中使用了一个名为api_key的属性,碰到http header不转发的问题。

    问题源码:

    rc = ngx_http_parse_header_line(r, r->header_in, cscf->underscores_in_headers);

    if (r->invalid_header && cscf->ignore_invalid_headers)

    在ngx_http_parse_header_line() 函数中;

    if (ch == ‘_’) {
                    if (allow_underscores) {
                        hash = ngx_hash(hash, ch);
                        r->lowcase_header[i++] = ch;
                        i &= (NGX_HTTP_LC_HEADER_LEN – 1);

                    } else {
                        r->invalid_header = 1;
                    }

    红色部分就是问题所在了

    原来是对header name的字符做了限制,默认 underscores_in_headers 为off,表示如果header name中包含下划线,则忽略掉。

    1:配置中http部分 增加underscores_in_headers on; 配置

    2:用减号-替代下划线符号_,避免这种变态问题。nginx默认忽略掉带下划线的header。

  • 相关阅读:
    20180530
    vue路由配置出错,导致页面跳转会有闪屏问题
    20180528
    vuecli+ivew项目搭建
    centos6安装mysql
    华为云服务ESC
    centos6安装nginx
    国产操作系统aarch64编译filebeat
    Python常见问题
    Git
  • 原文地址:https://www.cnblogs.com/arli/p/7002142.html
Copyright © 2011-2022 走看看