一 概述
1.1 需求描述
- 服务端地址:在192.168.152.138服务器上的tomcat的目录 testhb存放一个hello.html页面,如下图所示
真实地址:http://192.168.152.138:8080/testhb/hello.html
2.现在不想把192.168.152.138:8080 暴露在外面,在192.168.152.2 机器上代理此请求 http://192.168.152.138:8080/testhb/hello.html
3.目的:代理地址 http://192.168.152.2:80/api/testhb/hello.html 被代理地址(真实地址):http://192.168.152.138:8080/testhb/hello.html
1.2 情况列举
设置A=192.168.152.2:80 ; B=192.168.152.138:8080
访问路径 |
Location配置 |
Proxy_pass配置 |
被搭理后的地址 |
正确访问的地址 |
A/api/testhb/hello.html |
/api/ |
B/ |
B/testhb/hello.html |
B/testhb/hello.html |
A/api/testhb/hello.html |
/api/ |
B |
B/api/testhb/hello.html |
B/testhb/hello.html |
A/api/testhb/hello.html |
/api |
B/ |
B//testhb/hello.html |
B/testhb/hello.html |
A/api/testhb/hello.html |
/api |
B |
B/api/testhb/hello.html |