skip to Main Content

I have two spring boot web applications. I want those applications to be deployed on same port with different endpoints, like

  • Application 1 – xx.xx.xx.xx:80/app1
  • Application 2 – xx.xx.xx.xx:80/app2

I am trying to deploy these applications using docker in AWS EC2. Please let me know how to do this.

Thank you!

When I tried to deploy two applications on same port, it failed.

2

Answers


  1. You can’t have two apps on a single machine listening on the same port. Can you put both endpoints in the same application?

    Login or Signup to reply.
  2. Having two apps running on the same port on a single machine is impossible. However, you can run applications on each port and combine them using Nginx.
    Example:

    • Application A (/app1) is running on 8080

    • Application B (/app2) is running on 8081

    • And the below Nginx Config might cover your case, I guess.

      listen 80;
      
       location /app1 {
           proxy_pass http://localhost:8080;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto $scheme;
       }
      
       location /app2 {
           proxy_pass http://localhost:8081;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto $scheme;
       }
      
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search