场景
不同的子系统(不同ip或端口)想通过同一域名端口 实现转发请求。
例如
a系统 a.com:8097/index.html
b系统 b.com:8098/index.html
统一由域名转发weny7.com
访问 weny7.com/a/ ==> a.com:8097/a/
访问 weny7.com/b/ ==> b.com:8098/b/
配置
haproxy
acl is_ds-frame-web url_beg /a/
acl is_ds-comprehensive-web url_beg /b/
#页面调用的接口加上转发规则
acl is_ds-authorization-api url_beg /ds-authorization-api/
acl is_ds-system-manager-api url_beg /ds-system-manager-api/
use_backend ds-frame-web_back if is_ds-frame-web
use_backend ds-comprehensive-web_back if is_ds-comprehensive-web
use_backend ds-authorization-api_back if is_ds-authorization-api
use_backend ds-system-manager-api_back if is_ds-system-manager-api
#页面转发
backend ds-frame-web_back
balance source
server a.com a.com:8097 check
#页面转发
backend ds-comprehensive-web_back
balance source
server b.com b.com:8098 check
#接口转发
backend ds-authorization-api_back
balance source
reqrep ^([^\ ]*\ /)ds-authorization-api[/]?(.*) \1\2
#http-request replace-path /web1(.*) \1 #2.1版本之后用http-request 来去除前缀
server 161.0.240.234 161.0.240.234:8090 check
#接口转发
backend ds-system-manager-api_back
balance source
reqrep ^([^\ ]*\ /)ds-system-manager-api[/]?(.*) \1\2
#http-request replace-path /web1(.*) \1
server 161.0.240.234 161.0.240.234:8082 check
nginx
server {
listen 8097;
server_name localhost;
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /ds-analysis-web/index.html; #针对angualr 两层目录
}
}
server {
listen 8098;
server_name localhost;
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
站点放置目录
vue打包配置
angular配置
打包指令加上 base-href = /b/
Q.E.D.