nginx的安装使用这些我就不介绍了,不会的自己去搜索吧,很简单,下载--解压--启动--关闭 就这么多
简介
网关(Gateway)又称网间连接器、协议转换器。网关在网络层以上实现网络互连,是复杂的网络互连设备,仅用于两个高层协议不同的网络互连。网关既可以用于广域网互连,也可以用于局域网互连。 网关是一种充当转换重任的计算机系统或设备。使用在不同的通信协议、数据格式或语言,甚至体系结构完全不同的两种系统之间,网关是一个翻译器。与网桥只是简单地传达信息不同,网关对收到的信息要重新打包,以适应目的系统的需求。同层--应用层。-----来源 百度百科-网关
准备工作

1.先把nginx复制两份出来,模拟成两个服务,一个是serverA一个是serverB
2.修改两个服务的端口 config-->nginx.conf

3.修改下index.html , 方便后面辨别

4.启动serverA和serverB看下是否修改成功


5.开始配置统一网关(nginx-->config-->nginx.conf)也就是图一的第一个nginx的配置文件,加上下面的代码

location /a {
proxy_pass http://127.0.0.1:7001/;
index index.html index.htm;
}
location /b {
proxy_pass http://127.0.0.1:8001/;
index index.html index.htm;
}
6.现在开始访问
server : http://127.0.0.1/

server-a: http://127.0.0.1/a

server-b: http://127.0.0.1/b

OK大功告成
有不懂的地方或者其他问题请联系我: http://litao1104.cn/
网友评论