用uwsgi_pass覆盖nginx请求头



是否有办法让nginx 而不是将特定的请求头转发给uwsgi?

我想启用nginx的基本授权,但如果Authorization头被转发到我的应用程序它破坏的东西(原因,我不会进入)。如果它只是一个简单的proxy_pass,我将能够做proxy_set_header Authorization "";,但我不认为这适用于uwsgi_pass,而且据我所见,没有等效的uwsgi_set_header

谢谢。

尝试隐藏header并忽略header指令:

uwsgi_hide_header

语法:uwsgi_hide_header field;默认值:-上下文:http, server,位置

默认情况下,nginx不传递报头字段" Status "one_answers"X-Accel -…从uwsgi服务器到客户端的响应。的Uwsgi_hide_header指令设置了不需要的附加字段过去了。相反,如果字段的传递需要如果允许,可以使用uwsgi_pass_header指令。

uwsgi_ignore_headers

语法:uwsgi_ignore_headers field…;默认值:-

Context: http, server, location禁止处理某些来自uwsgi服务器的响应头字段。以下字段可以忽略:" X-Accel-Redirect ", " X-Accel-Expires ",(1.1.6),"X-Accel-Limit-Rate X-Accel-Buffering"(1.1.6)," X-Accel-Charset " (1.1.6), " Expires ", " Cache-Control ", " Set-Cookie "(0.8.44)和"Vary"(1.7.7)。

如果未禁用,这些报头字段的处理如下效果:

" X-Accel-Expires ", " Expires ", " Cache-Control ", " Set-Cookie "等"Vary"设置响应缓存的参数;"X-Accel-Redirect"执行内部重定向到指定的URI;"X-Accel-Limit-Rate"设置a的传输速率限制对客户的响应;"X-Accel-Buffering"启用或禁用缓冲响应;" X-Accel-Charset "设置所需的字符集响应。

这对你来说可能太晚了,但对于任何有同样问题的人来说,这个答案提供了一个有效的解决方案。

在这种情况下,Authorization头可以通过以下指令传递:

uwsgi_param  HTTP_Authorization "";

最新更新