如何解决使用 nginx 反向代理,url 与 curl 一起使用,但不适用于 chrome
我正在处理一个学校项目,并尝试使用 docker compose 将地址反向代理到另一个 docker 容器。
http://localhost
--> nginx 网页
http://localhost/web/
AND http://localhost/web
--> 反向代理到另一个容器(已经在同一网络上)
我正在使用命令 curl -I
测试结果,它似乎适用于下面的 nginx 配置。它也适用于 Internet Explorer。但是在这种情况下它不适用于 chrome http://localhost/web
(没有尾部斜杠),chrome 正在将 url 更改为:http://localhost/127.0.0.2:5050
并且我收到 404 Not found 错误。
我希望这两种情况都适用于 chrome。
NGINX 配置:
user www;
events {
worker_connections 1024;
}
http {
upstream web_server{
server web-service:9000;
}
server {
listen 80;
root /www;
index index.html index.htm;
location ~ ^/web(?:/(.*))?$ {
proxy_pass http://web_server/$1;
}
}
}
卷曲命令 curl -I http://localhost/wordpress
结果:
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Tue,11 May 2021 08:38:58 GMT
Content-Type: text/html
Content-Length: 261
Connection: keep-alive
Last-Modified: Mon,10 May 2021 09:04:49 GMT
ETag: "6098f731-105"
Accept-Ranges: bytes
卷曲命令 curl -I http://localhost/wordpress/
结果:
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Tue,11 May 2021 08:39:04 GMT
Content-Type: text/html
Content-Length: 261
Connection: keep-alive
Last-Modified: Mon,10 May 2021 09:04:49 GMT
ETag: "6098f731-105"
Accept-Ranges: bytes
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。