当我调用 localhost:81/internal?pageId=10 时,我尝试从另一个内部服务加载 Angular 应用。但发生的一切只是 nginx 在浏览器中将我重定向到 localhost:80。
我有这样的配置:
location ~ /internal(?<section>.+) {
proxy_pass http://192.168.1.100:8080/public/internal$section;
proxy_set_header Host $host;
}
正如我在其他多个问题中读到的那样,这应该可行,但由于某种原因,nginx 将我重定向到端口 80。
请求标头:
GET /internal/?pageId=10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Host: localhost:81
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36
响应标头:
HTTP/1.1 302 Found
Server: nginx/1.21.6
Date: Thu, 19 May 2022 09:15:34 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Location: http://localhost/public/internal?pageId=10
X-Powered-By: Jetty(9.4.40.v20210413)
这有可能吗?如果可能,我该如何解决这个问题?