Multiple Domains for GlassFish

Running Multiple Custom Domains on GlassFish Server

A single GlassFish environment can serve one Java application through several custom domain names. The domains are bound to the environment and then assigned to a GlassFish virtual server.

GlassFish provides enterprise-ready Java application hosting with an administration panel for application deployment, listener configuration, and virtual-server management.

Create the GlassFish Environment

1Open the environment wizard

Sign in to the platform dashboard and click Create environment or New Environment.

2Select GlassFish

Choose GlassFish as the application server, configure the required Cloudlet limits, enter the environment name, and click Create.

Create a GlassFish environment
Select GlassFish, configure the resources, and create the environment.

After provisioning is complete, the environment appears in the dashboard.

GlassFish environment created
The GlassFish environment is ready for domain binding and application deployment.

Configure and Bind the Domains

Create the required DNS records for every custom domain. Depending on the network setup, use a CNAME record or the appropriate A record.

3Open Custom Domains

Click Settings beside the environment and open the Custom Domains section.

4Bind every domain

Enter each domain and click Bind. The example uses myapplication.com and myapplication.org.

Bind custom domains to the GlassFish environment
Bind all required custom domains to the same environment.
For local testing, domain entries can be added to the computer’s hosts file. Such entries work only on the machine where that hosts file was modified.

Deploy the Application

When the environment is created, the platform provides a link and credentials for the GlassFish DAS administration node.

5Open the GlassFish administration panel

Use the provided credentials to sign in and open the Applications section.

GlassFish Applications section
Use the GlassFish administration panel to deploy the Java application.

Deploy the required application package and confirm that the web module is available before creating the virtual server.

Create a GlassFish Virtual Server

6Open Virtual Servers

Navigate to Configurations > default-config > Virtual Servers and click New.

GlassFish Virtual Servers section
Create a new virtual server under the default GlassFish configuration.

7Configure the virtual server

Complete the required fields and save the configuration.

ID Enter a unique identifier for the new virtual server.
Hosts Enter the bound custom domains as a comma-separated list.
HTTP Listeners Select the listener that should process requests for these domains.
Default Web Module Select the deployed application that should be opened for the configured domains.
Configure a GlassFish virtual server
Assign the custom domains, HTTP listener, and web module to the virtual server.
Domain format: Enter multiple host names as a comma-separated list without adding the URL protocol, for example myapplication.com,myapplication.org.

Save and Verify the Domains

8Save the configuration

Save the virtual-server settings. Restart GlassFish if the updated configuration is not applied automatically.

Open every configured domain in a browser. Each one should load the web module assigned to the new GlassFish virtual server.

Application available through multiple GlassFish domains
The same application is accessible through all configured custom domain names.
For HTTPS access, install an SSL certificate that covers all required domains and assign it to the appropriate listener or platform SSL configuration.

What’s next?