nginx如何配置二级目录访问另一台机器上apache代理的原生php项目
运行环境#
虚拟机 hostA: centos7 + nginx
本机电脑 hostB:windows + html + apache
虚拟机 A 的 ip 是 x.x.x.222
本机电脑 B 的 ip 是 x.x.x.111
详细环境#
虚拟机 A 中做了如下操作
修改 host
127.0.0.1 hostB x.x.x.111 hostA
nginx 的配置文件路径是
/etc/nginx/nginx.conf
在配置文件的 server 块中添加了如下配置
location /aaa/ { proxy_pass hostB; }
本机电脑 B 做了如下操作
- 修改 host 文件
127.0.0.1 hostB x.x.x.222 hostA
- apache 的配置文件未改变,默认执行的 web 目录为
xxxxx/xampp/htdocs
- web 目录下添加了一个
index.html
文件,index.html
内容如下. . . <body> <h1>hello1</h1> <a href="/hello">hello</a> </body> . . .
我遇到的问题#
在浏览器中访问 hostA/aaa
得到的页面和 index.html
的内容一致。
打开开发者工具,鼠标悬浮在 a 标签上出现一个提示框,提示框内容是 hostA/hello
我的理想结果#
鼠标悬浮在 a 标签的地址是 hostA/aaa/hello
我的问题#
遇到上述情况我应该怎么配置 nginx 呢?
推荐文章: