3

i have a multiple domains on my centos vps (domains running on apache http server via virtual host configurations). and also same vps, i want to add my new domain but that domain will route my spring boot application (application is a jar file also inside embedded tomcat ). i couldn't find any configuration for embedded tomcat specific domains and ports.

standalone Tomcat i can make configuration via server.xml file like this image

also this short tutorial shows configuration for stadalone tomcat Tomcat Virtual Host Configuration

But how can i do that configuration for embedded Tomcat ? Any suggestion ?

cekil
  • 56
  • 1
  • 5
  • Most of the configuration are available in application.properties which internally updates server.xml. The properties to be changed are given in thttp://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html (all the properties with server.tomcat are related to that) – Nagappan Nov 09 '15 at 11:42
  • thanks for answer. I already read that page also i read that common application.properties [link] (http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#common-application-properties) but couldn't solve my problem. Also i find that question on stackoweflow [link] (http://stackoverflow.com/questions/23946369/how-to-configure-embedded-tomcat-integrated-with-spring-to-listen-requests-to-ip) that question answered as server.address= but i have one ip and multiple domains on same machine.. – cekil Nov 09 '15 at 11:52
  • multiple domains means i didn't get it. Is it multiple host.If you could state some example it would be helpful to give the answer. – Nagappan Nov 09 '15 at 12:02
  • i mean, i have one virtual private server. on that server i have **www.burakkayacan.com**, **test.burakkayacan.com** domains. apache httpserver receive that domains request and routes different folder via apacahe http virtual host configuration. and also i have spring boot application on vps inside specific folder. when i enter **blog.burakkayacan.com** on browser, that request should route spring boot application.i can that config. but standalone tomcat virtual host configuration in server.xml file adding host node inside xml (http://i.stack.imgur.com/SXsA7.jpg) but cannot for spring boot ? – cekil Nov 09 '15 at 12:13

2 Answers2

2

With Spring Boot embedded Tomcat, you are hosting only one application per servlet container. So I don't believe that Tomcat's concept of Virtual Hosts make sense at all.

If you have to host your app on shared Tomcat instance, just build WAR without embedded container.

luboskrnac
  • 23,973
  • 10
  • 81
  • 92
  • thanks for answer. on my vps there is a apache http server and three domains on that server . i configured that domains via virtual host conf file. and also i have blog website that is spring boot application. but why i can not configuration via **application.properties** file or specification of **EmbeddedServletContainerAutoConfiguration** class like that application will receive **blog.burakkayacan.com** ? my latest solution will be war file but spring documentation and webinar they are suggest make jar file for deployment. – cekil Nov 09 '15 at 12:55
  • As I mentioned, embedded tomcat is meant for 1 app 1 tomcat instance approach. If you are using Shared Tomcat instance, you have to build WAR instead of fat JAR. – luboskrnac Nov 09 '15 at 13:29
0

It depends. 2 ways to deploy your project.jar as you want to :

First way : You can use the "apache web server" and his own "mod_proxy" in order to serve as many Spring webapps you want to, each on a specific port configured with "php-fpm" and with a proxy defined to route requests from/to your namebased VirtualHost configuration.

Nowadays, with Spring Boot 2.5, all you have to do is to set the property server.port in your application.properties file, and use it accordingly with mod_proxy directives. If you are using profile, you can either set one port to dev or prod or test or whatever properties file you need.

Another way to proceed : you can use the apache web server "mod_jk" bridge module to configure multiple load-balancers for your Virtualhosts too.

Choose your path, young Jedi ;)

This response is certainly not for the OP, 7 years later, but for other people whom are using any web search engine like Google. They will come here and see "something is impossible". It is not true.

BendaThierry.com
  • 2,080
  • 1
  • 15
  • 17