第一种ngx方式
server {
listen 8088;
server_name localhost;
location / {
proxy_pass http://localhost:8000/;
}
location monitor/ {
proxy_pass http://localhost:8001/;#这里注意ract项目本身带了monitor前缀,所以源路径不需要配置前缀,代理路由需要配置
}
location /monitor-intf {
proxy_pass http://127.0.0.1:8085/monitor-intf;
}
}
第二种方式直接用react项目脚手架自带的proxy.js代理转发
dev: {
'/monitor': {
target: 'http://127.0.0.1:8088/',
changeOrigin: true,
pathRewrite: {
'^': '',
},
},
},