Cannot get header that contains a period from NGINX

ⅰ亾dé卋堺 提交于 2021-02-08 10:01:33

问题


The header "Abp.TenantId" is null because of the ".".

If remove the "." (like "AbpTenantId"), it will be ok.

How to add a header with a "."?

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

localhost debug:

  1. Provisional headers are shown (show this on client request)
  2. Request.Headers.Unknown (show this in server, api action)
  3. Request.Headers.MaybeUnknown (show this in server, api action)

localhost is ok.

The same code in server, but server error.

The code for the tenantId:

The logs have no tenantId, so error:

localhost is ok:

Server fail:


回答1:


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

ABP 4.4+

TenantIdResolveKey is configurable:

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

Below ABP 4.4

You can turn off ignore "invalid" headers in Nginx:

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

Controls whether header fields with invalid names should be ignored. Valid names are composed of English letters, digits, hyphens, and possibly underscores (as controlled by the underscores_in_headers directive).

If the directive is specified on the server level, its value is only used if a server is a default one. The value specified also applies to all virtual servers listening on the same address and port.



来源:https://stackoverflow.com/questions/49783689/cannot-get-header-that-contains-a-period-from-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!