Home > Net >  Multiple application on single PC
Multiple application on single PC

Time:10-31

I have installed Tomcat server on my server PC with IP 127.0.0.1 One application is running on the server. Let address of the application is: 127.0.0.1:8080/first-project Now if I want to run another application on the same server, address will be: 127.0.0.1:8080/second-project

I want multiple application with multiple addresses like 127.0.0.1, 127.0.0.2

a) Is this possible to have multiple address on single PC?

b) What is the best practice for running multiple server on same server and how to do that?

  1. With different IP address (127.0.0.1, 127.0.0.2)
  2. With same IP address but different port (127.0.0.1:8080, 127.0.0.1:8081)
  3. With same IP different path (127.0.0.1/first, 127.0.0.1/second)

Any resource link will be helpful. Thanks in advance.

CodePudding user response:

Not an expert of networking, but what I would suggest to you is the following

  1. You can have many application running on the same server, in the same Tomcat Server but you have to set differents ports. Example : http://localhost:8080/ or http://localhost:8082/ or http://localhost:8084/
  2. You can run your applications in Docker. Then you will be able to run your application in an isolated container with its own IP address. With Docker, you can use docker-compose to run many containers
  3. You can run your applications in differents virtual machines. You will be able to configure each virtual machines with their own IP address to interact with your host or from external location.
  4. You can, have multiple IP address on a single network card

CodePudding user response:

You cannot have several ip addresses on one machine, that's what ports are for. You assign a port to an application, in application.properties, eg. server.port = 8081.

Now, paths are assigned by Controllers and their methods, eg.

@Controller("/first")
publc class FirstController {

    @GetMapping("/hello")
    public String hello() {
        return "Hello world!";
    }
}

edit I think you're talking about the context path, which you can specify also in application.properties like so: server.servlet.context-path = /mycontext.

  • Related