为了方便演示 这里使用 windows 安装 nginx
nginx.conf的文件 添加相关配置
server {
listen 9001;
server_name localhost;
location ~ /hosp/ {
proxy_pass http://localhost:8201;
}
location ~ /cmn/ {
proxy_pass http://localhost:8202;
}
location ~ /user/{
proxy_pass http://localhost:8201;
}
}
启动nginx 双击nginx.exe 窗口一闪而过
查看任务管理器 出现两个进程 一个主进程 一个工作进程
配置前端请求 http://localhost:9001,根据请求的路径 匹配相应的服务器 controller层的路径匹配
请求:htttp://localhost:9001/admin/user/user/login 匹配: http://localhost:8201/admin/user/user/login
请求:htttp://localhost:9001/admin/hosp/hospitalSet/findAll 匹配:http://localhost:8202/admin/hosp/hospitalSet/findAll