对于server配置:
//该文件配置在自己需要跳转的那个机器上面,例如:我的机器是127.0.0.3 ,目的的机器ip: 127.0.0.2 那么该配置就是在127.0.0.3 这个机器ip上面实现对应的配置,才能实现对应的反向代理。 该监听的端口就是就自己需要访问的端口也就是 127.0.0.3:8081 访问方式实现。
server {
listen 8081; //监听的端口,也就是自己访问服务器需要使用的端口,注意此处端口不能与tomcat端口一样,否则端口被占用。需要实现不同的端口服务操作
server_name locahost; //服务名称,一般是自己也是可以进行调整
location /fw-basic-web/api/role/ { //访问的项目的地址实现
proxy_pass http://ip:8081/fw-system-web/api/role/; //轮询的项目地址
proxy_redirect http://目的ip:8081/fw-system-web/api/role/ http://访问ip:8081/fw-basic-web/api/role/;
// 通过访问后面的ip数据实现对应的访问到目的ip数据的地址实现数据获取实现。
}
location /fw-basic-web/api/fw/ {
proxy_pass http://127.0.0.2:8081/fw-basic-web/api/fw/;
proxy_redirect http://127.0.0.2:8081/fw-basic-web/api/fw/ http://127.0.0.3:8081/fw-basic-web/api/fw/;
}
//访问的项目也是需要对应的跳转
location /fw-basic-web {
proxy_pass http://目的ip:8081/fw-basic-web;
proxy_redirect http://127.0.0.3:8081/fw-basic-web http://127.0.0.2:8081/fw-basic-web;
}
}