我有一个凤凰框架应用程序部署与云运行与多个客户端使用它。
由于云运行后台任务的限制,我想将部署转移到计算机引擎,但我不想强迫客户端更新他们的应用程序(即后端url)。
所以我想我可以在云运行中部署一个Ngnix实例,它可以将所有东西重定向到Compute引擎。
问题是,我使用的授权请求头没有到达菲尼克斯连接。我尝试过使用不同的服务器(),它正确地接收每个标头。
所以问题是。如果某些请求头来自重定向,那么菲尼克斯框架会过滤掉它们吗?
标题是:{"authorization", "Bearer XXX"}
ngixn.conf只是:
server {
listen 80;
return 301 http://0.0.0.0:4000$request_uri;
}检查conn.req_headers的目的是:
$curl -L --location --request GET 'http://localhost:80' \
--header 'Content-Type: application/json' --header 'other: whatever' \
--header 'Authorization: Bearer XXXX' \
--data-raw ''`检查结果如下:
[
{"accept", "*/*"},
{"content-type", "application/json"},
{"host", "0.0.0.0:4000"},
{"other", "whatever"},
{"user-agent", "curl/7.54.0"}
]如果将卷曲直接转到菲尼克斯服务器应用程序,请使用:
curl -L --location --request GET 'http://localhost:4000' \
--header 'Content-Type: application/json' --header 'other: whatever' \
--header 'Authorization: Bearer XXXX' \
--data-raw ''`我们有:
[
{"accept", "*/*"},
{"authorization", "Bearer XXXX"},
{"content-length", "0"},
{"content-type", "application/json"},
{"host", "localhost:4000"},
{"other", "whatever"},
{"user-agent", "curl/7.54.0"}
]编辑的
Python服务器也不接收授权头。
直接向服务器提出请求:
127.0.0.1 - - [03/Nov/2020 07:22:30] "GET / HTTP/1.1" 200 -
Host: localhost:4000
User-Agent: curl/7.54.0
Accept: */*
Content-Type: application/json
other: whatever
Authorization: Bearer XXXX
Content-Length: 0通过Nginx重定向的请求:
127.0.0.1 - - [03/Nov/2020 07:22:41] "GET / HTTP/1.1" 200 -
Host: 0.0.0.0:4000
User-Agent: curl/7.54.0
Accept: */*
Content-Type: application/json
other: whatever所以我猜Nginx是‘捕获’了auth头,并且不让它通过。
发布于 2020-11-03 10:07:33
这是卷发的一个特征。如果请求被重定向到不同的主机名,那么在第二个请求中将删除任何Authorization头,以避免向无关服务器泄漏凭据。(您正在向localhost:80发出请求,但重定向位置是0.0.0.0:4000,因此这是一个不同的主机名。)
通过使用Authorization选项而不是-L,您可以获得curl来转发--location-trusted头。
(虽然您看到的curl 7.54.0很奇怪,但根据这个安全咨询的说法,curl7.54.0应该按照您的预期行事,而且只有7.58.0及更高版本具有这种保护功能。)
https://stackoverflow.com/questions/64634788
复制相似问题