项目前端采用nginx代理.后端有2个war包.分别访问2个数据库.端口分别为8030和8040
前端请求URL路径包含history转发到8030,其余路由到8040.
配置如下
server {
listen 8090;
server_name 127.0.0.1;
location /{
root /home/tomcat/font/dist;
index index.html login.html login.htm;
try_files $uri $uri/ /index.html;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
location ^~/server_context/history/ {
rewrite ^/server_context/history/(.*) /server_context/$1 break;
proxy_pass http://127.0.0.1:8030;
}
location ^~/server_context/ {
proxy_pass http://127.0.0.1:8040/server_context/;
}
}