Iag*_*íaz 1 redirect nginx elixir phoenix-framework
我有一个使用 Cloud Run 部署的 Phoenix 框架应用程序,有多个客户端使用它。
由于 Cloud Run 后台任务限制,我想将部署移至 Computer Engine,但我不想强制客户端更新其应用程序(即后端 url)。
因此,我认为我可以在 Cloud Run 中部署一个 Ngnix 实例,将所有内容重定向到 Compute Engine。
问题是我使用的授权请求标头无法到达 Phoenix 连接。我已经用不同的服务器(Python simpleserver)尝试过,它正确地接收了每个标头。
所以,问题是。Phoenix 框架是否会过滤掉来自重定向的某些请求标头?
标题是:
{"authorization", "Bearer XXX"}
ngixn.conf 很简单:
server {
listen 80;
return 301 http://0.0.0.0:4000$request_uri;
}
Run Code Online (Sandbox Code Playgroud)
检查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 ''`
Run Code Online (Sandbox Code Playgroud)
检查给出:
[
{"accept", "*/*"},
{"content-type", "application/json"},
{"host", "0.0.0.0:4000"},
{"other", "whatever"},
{"user-agent", "curl/7.54.0"}
]
Run Code Online (Sandbox Code Playgroud)
如果直接使用 curl 到 Phoenix 服务器应用程序:
curl -L --location --request GET 'http://localhost:4000' \
--header 'Content-Type: application/json' --header 'other: whatever' \
--header 'Authorization: Bearer XXXX' \
--data-raw ''`
Run Code Online (Sandbox Code Playgroud)
我们有:
[
{"accept", "*/*"},
{"authorization", "Bearer XXXX"},
{"content-length", "0"},
{"content-type", "application/json"},
{"host", "localhost:4000"},
{"other", "whatever"},
{"user-agent", "curl/7.54.0"}
]
Run Code Online (Sandbox Code Playgroud)
已编辑
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
Run Code Online (Sandbox Code Playgroud)
通过 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
Run Code Online (Sandbox Code Playgroud)
所以我猜 Nginx 正在“捕获”auth header 并且不让它通过
| 归档时间: |
|
| 查看次数: |
1201 次 |
| 最近记录: |