[英]How may I forward a non standard application specific header from nginx to my application server?
I have not been able to pass an application specific header to my application that is running on uWSGI and Flask我无法将特定于应用程序的 header 传递给我在 uWSGI 和 Flask 上运行的应用程序
This is from my nginx.conf这是来自我的 nginx.conf
proxy_pass http://localhost:5000/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_pass_request_headers on;
proxy_set_header $HTTP_Chart-Type $http_chart_type;
}
These are my headers from chrome:这些是我来自 chrome 的标题:
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cache-Control: no-cache
chart_type: line
I am trying to pass the chart_type header to my backend.我正在尝试将 chart_type header 传递到我的后端。
Thanks谢谢
The default value of proxy_pass_request_headers
is on
, so there should be no need to explicitly set it (unless it is turned off in the config somewhere and that has an effect on your configuration). proxy_pass_request_headers
的默认值是on
,因此不需要显式设置它(除非它在某处的配置中被关闭并且对您的配置有影响)。
With the default setting ( on
), Nginx passes all headers to the backend, so you don't need any special configuration to pass a custom header (assuming your http_chart_type
is a custom header).使用默认设置 ( on
),Nginx 将所有标头传递到后端,因此您不需要任何特殊配置即可传递自定义 header(假设您的http_chart_type
是自定义标头)。
Your problems passing the http_chart_type
header from Nginx to the backend is likely related to Nginx by default not allowing header names with underscore.您将http_chart_type
header 从 Nginx 传递到后端的问题可能与 Nginx 默认情况下不允许带有下划线的 header 名称有关。 See https://stackoverflow.com/a/74798560/3571 .请参阅https://stackoverflow.com/a/74798560/3571 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.