1.首先前端请求的地址如下:
http://ucenter.xuecheng.com/#/learning/4028e581617f945f01617f9dabc40000/2
2.通过SwitchHosts的映射 127.0.0.1 ucenter.xuecheng.com映射到本机上来,而不去寻找外网。
3.然后查看nginx.conf的配置中的配置,映射到了前端13000(xc-ui-pc-learning)的服务中来。
#前端ucenter
upstream ucenter_server_pool{
server 127.0.0.1:13000 weight=10;
}
#学成网用户中心
server {
listen 80;
server_name ucenter.xuecheng.com;
#个人中心
location / {
proxy_pass http://ucenter_server_pool;
}
通过查看下面的路由跳转到了learning_video.vue页面中来。
然后通过钩子函数。取出路由中的课程id,和章节id。同时调用 systemApi.course_view()方法。
然后查看该方法如下:
继续通过nginx.conf文件的映射到服务端40100中的服务中
#后台搜索(公开api)
upstream search_server_pool{
server 127.0.0.1:40100 weight=10;
}
#学成网用户中心
server {
listen 80;
server_name ucenter.xuecheng.com;
#个人中心
location / {
proxy_pass http://ucenter_server_pool;
}
#后端搜索服务
location /openapi/search/ {
proxy_pass http://search_server_pool/search/;
}
```