One of the solutions for deploying a distributed system with dual IPs on the server

1. Background:

        Due to project requirements, the development is distributed in a distributed manner. According to different functional modules, it is divided into different subsystems, and each subsystem has its own ip. But when it came time to deploy, the problem came. The deployed server is a server of the school, and there is only one server (ps: the distributed system is deployed on one server, I feel a little tired thinking about it). This is not the point. The point is that this server has dual IPs, which are divided into LAN IP and WAN IP. The local area network IP is used inside the school, and the WAN IP is used outside the school.

2. Difficulties:

         If it is a single server system, using a nginx for reverse proxy will solve the problem, but single sign-on needs to return the address, allowing users to transfer to other subsystems. So nginx this method does not work.

3. Solutions

        I found a temporary solution: by intercepting and getting the user's request path. And intercept the prefix of the user's request path, and then splice the suffixes of each subsystem in the background, and then return to the foreground, which can temporarily solve the problem of dynamic ip.

The Java code is as follows:

After obtaining the prefix, splicing the path to access each subsystem (the path of each subsystem is read in the configuration file), so that the problem can be temporarily solved. Note: If the ip is through a reverse proxy or has a domain name, this needs to be adjusted according to your own needs

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325935204&siteId=291194637