Multiple Domains for GlassFish

Multiple Domains for GlassFish

Multiple custom domain names can be configured for Java applications running on a GlassFish application server. GlassFish virtual servers allow separate host names to be served from the same server instance while sharing the underlying server resources.

Deploy application on GlassFish

Create a GlassFish Environment

Create a new environment and select GlassFish as the application server. Configure the required cloudlet/resource limits, enter the environment name, and complete environment creation.

After provisioning is completed, the GlassFish environment appears in the dashboard and is ready for application deployment and domain configuration.

Deploy Applications

GlassFish virtual server configuration

Upload and deploy the Java applications that should be available through your custom domains. Each application can use its required deployment context.

Configure GlassFish Virtual Servers

GlassFish virtual servers make it possible for a single HTTP server process to handle different domain names. Create the required virtual servers and associate each one with its corresponding host name and application.

  1. Open the GlassFish Administration Console.
  2. Navigate to the HTTP Service or Virtual Servers configuration.
  3. Create a new virtual server.
  4. Specify a unique virtual-server ID.
  5. Enter the required custom domain in the Hosts configuration.
  6. Associate the virtual server with the appropriate HTTP/network listener.
  7. Save the configuration.
GlassFish environment creation

Tip: Virtual servers allow multiple domain names to be served from the same GlassFish instance without requiring a separate application-server instance for every domain.

Associate Domains with Applications

Configure each virtual server so requests received for its host name are directed to the intended application. Repeat this process for every additional domain that should be handled by the GlassFish environment.

www.example-one.com  →  Virtual Server 1  →  Application 1
www.example-two.com  →  Virtual Server 2  →  Application 2

Configure DNS Records

After configuring GlassFish, point each custom domain to the environment through DNS.

  • When the environment is accessed through a shared load balancer, configure the appropriate CNAME record.
  • When the environment uses a public IP address, point the domain to that IP with an A record.
  • Allow sufficient time for DNS changes to propagate before testing.

Note: Both parts are required: the domain must resolve to the environment through DNS, and GlassFish must be configured to recognize the corresponding host name.

Verify the Configuration

  1. Confirm that each custom domain resolves to the environment.
  2. Open each domain in a web browser.
  3. Verify that GlassFish selects the correct virtual server.
  4. Confirm that the intended application opens for each domain.

Important Notes

  • Multiple virtual servers can operate within a single GlassFish instance.
  • Virtual servers can use separate domain names while sharing the same physical resource pool.
  • Each host configuration should be unique where required by the GlassFish listener configuration.
  • Use the appropriate DNS configuration for the selected external-access method.
  • Test all domains after DNS propagation and after changing GlassFish settings.