Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serve mulitple web applications on different subdomains?

Not sure if the title is well suited but I am having three apps (static content) at the moment:

  • public
  • app
  • admin

public is just content which is just for the regular web, app is content which is rendered for mobile devices and admin is basically a tool for administrative stuff. They are all contained in the same Spring Boot application and talk to the REST API at example.com/api. Technically, I could just place them into resources/static such that

resources/static/public
resources/static/admin
resources/static/app

which would allow me to access the apps as such:

example.com/public/index.html
example.com/admin/index.html
example.com/app/index.html

However, my goal is to have the following structure:

      example.com     // For public
admin.example.com     // For admin
  app.example.com     // For app
      example.com/api // REST API

How can this be achieved or what can I do to make this possible?

like image 201
Stefan Falk Avatar asked Oct 30 '25 21:10

Stefan Falk


1 Answers

It sounds like you have three systems: public, admin and app sharing a common REST api. Probably the best approach would be to serve the static resources for each of the three systems using a content delivery network (CDN) like AWS CloudFront or Google Cloud CDN.

Another approach, though less desirable, would be to use a proxy to redirect app requests (for example https://admin.example.com to https://internal-spring-boot-server/admin). You could use Apache mod_proxy with reverse proxy (see https://httpd.apache.org/docs/2.4/mod/mod_proxy.html), or NGNX reverse proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

like image 100
Jean Marois Avatar answered Nov 01 '25 11:11

Jean Marois