Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name based virtual hosting with Spring Boot

I am looking for the best method to host multiple websites developed using Spring Boot.

I have a public IP and it points to EC2 machine.

Already I am running one web application on it, developed using Spring Boot.

Now, I am looking for a way to create my second Spring Boot application(running on a different port).

My configuration should result like this(Single public IP),

www.app1.com(x.x.x.x) => Spring Boot App1
www.app2.com(x.x.x.x) => Spring Boot App2

I found many articles on internet dealing with conf/server.xml file, http://tomcat.apache.org/tomcat-7.0-doc/config/host.html

Can someone help me to achieve the same

like image 814
Anantha Krishnan Avatar asked Apr 25 '14 10:04

Anantha Krishnan


People also ask

How do you name a virtual host?

To use name-based virtual hosting, you must designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the NameVirtualHost directive.

Can we use JBoss with Spring Boot?

With this configuration, the application is ready to deploy to any external application server. Once this is done, you can package your Spring Boot application as a war and deploy it to the JBoss server. To do that, you need to run mvn clean package , which will generate the war file.

What does SpringApplication run () do?

SpringApplication#run bootstraps a spring application as a stand-alone application from the main method. It creates an appropriate ApplicationContext instance and load beans. It also runs embedded Tomcat server in Spring web application.


1 Answers

The best way is probably to use a reverse proxy front end. E.g. install nginx on your EC2 box, or (probably better if you are serious about it) use an ELB, and Route 53 to register your DNS record.

like image 95
Dave Syer Avatar answered Oct 13 '22 00:10

Dave Syer