无法从NGINX获取包含句点的标题

时间:2018-04-11 20:08:54

标签: nginx asp.net-web-api asp.net-core header aspnetboilerplate

标题"Abp.TenantId"由于null而为"."

如果删除"."(例如"AbpTenantId"),则可以。

如何使用"."添加标题?

=============================================== ======

localhost debug:

  1. 显示临时标头(在客户请求中显示)
  2. Request.Headers.Unknown(在服务器中显示,api操作)
  3. Request.Headers.MaybeUnknown(在服务器中显示,api动作)
  4. localhost没问题。

    服务器中的代码相同,但服务器错误。

    tenantId的代码:

    enter image description here

    日志没有tenantId,因此错误:

    enter image description here

    localhost没问题:

    localhost success

    服务器失败:

    server fail

1 个答案:

答案 0 :(得分:1)

Nginx as a reverse proxy will not pass headers that contain a period.

ABP 4.4 +

TenantIdResolveKey可配置:

Configuration.MultiTenancy.TenantIdResolveKey = "Abp-TenantId";

ABP 4.4以下

您可以在Nginx中关闭ignore "invalid" headers

Syntax:  ignore_invalid_headers on | off;
Default: ignore_invalid_headers on;
Context: http, server
     

控制是否应忽略具有无效名称的标头字段。有效名称由英文字母,数字,连字符和可能的下划线组成(由underscores_in_headers指令控制)。

     

如果在服务器级别指定了该指令,则仅在服务器是默认服务器时使用其值。指定的值也适用于侦听同一地址和端口的所有虚拟服务器。