Vapor: Multi-level Subdomains

Jun, 28 2023#vapor

Vapor has always made it straightforward to deploy your application to a custom domain, subdomain, or even wildcard subdomain.

However, it’s only been possible to utilize single-level subdomains - meaning it was possible to deploy your application to, but not or

Today, we’re thrilled to announce support for multi-level subdomains on Vapor.

To take advantage of this feature, first, ensure the root domain is added as a domain to Vapor. This can be done either directly from the Vapor dashboard or by using the Vapor CLI:

vapor domain

Once the domain has been added, you must request a certificate. Wildcard certificates provided by AWS Certificate Manager can only protect single-level subdomains, so to protect a multi-level subdomain, the subdomain must be explicitly added to the certificate.

When requesting a certificate from the Vapor dashboard, you may explicitly add the multi-level subdomain by either adding it as the “Domain Name” or any of the “Alternative Names”.


Alternatively, you may request the certificate from the Vapor CLI:

vapor cert

When the certificate has been issued, you can add the multi-level subdomain to the domain section of your vapor.yml file and carry out a full deployment using the Vapor CLI. As previously discussed, wildcard certificates cannot protect multi-level subdomains, so the multi-level subdomain must be explicitly defined in the vapor.yml file - relying on wildcard subdomains is not possible.

id: 12345
name: vapor-rocks
            - 'composer install --no-dev'

Vapor will automatically find the correct certificate to protect the multi-level subdomain and attach it to your environment, regardless of whether you use API Gateway v1, API Gateway v2, or a load balancer.

That's it! Assuming you are using Vapor to manage your DNS, your application will be available via your multi-level subdomain when the deployment completes.

We hope you enjoy using this new feature of Vapor and look forward to hearing any feedback you may have!

By Joe Dixon

Software Developer at Laravel.

Find me on Twitter, GitHub or my blog.

Follow the RSS Feed.