Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MohamadSleimanHaidar's avatar

SSL for subdomain

I deployed my Laravel API through forge and have SSL turned on for the domain. I also have a Nextjs client setup that communicates with the API on the same server and domain. I setup a subdomain client.mydomain.com. However HTTPS is not enabled for the subdomain. Can anyone clarify whats the best approach to turn on SSL for subdomains?

0 likes
4 replies
LaryAI's avatar
Level 58

To enable SSL for a subdomain, you can follow these steps:

  1. Obtain a SSL certificate for the subdomain. You can either purchase one from a trusted certificate authority or use a free certificate from Let's Encrypt.

  2. Once you have the SSL certificate, you need to configure your web server to use it for the subdomain. The exact steps will depend on the web server you are using. If you are using Nginx, you can add a new server block for the subdomain in your Nginx configuration file. Here's an example:

server {
    listen 443 ssl;
    server_name client.mydomain.com;

    ssl_certificate /path/to/ssl_certificate.crt;
    ssl_certificate_key /path/to/ssl_certificate.key;

    # Other server configuration options
}

Make sure to replace /path/to/ssl_certificate.crt and /path/to/ssl_certificate.key with the actual paths to your SSL certificate and private key files.

  1. Restart your web server to apply the changes.

  2. Finally, update your DNS settings to point the subdomain to the correct IP address. This step is necessary for the SSL certificate to be recognized by the browser. You can do this by adding a new DNS record for the subdomain.

Once you have completed these steps, the subdomain should be accessible over HTTPS with a valid SSL certificate.

javierroman's avatar
Level 19

You have to turn on SSL for the subdomain the same way you did it for the domain. In Forge, in the site client.mydomain.com, go to SSL -> Let's Encrypt -> Obtain Certificate

1 like
MohamadSleimanHaidar's avatar

@javierroman Thank you. So I'll need to create a dedicated site on forge for my client using that subdomain right? I went through that setup manually on the server. Would you recommend that i create a new site on forge if i already have it setup?

javierroman's avatar

@MohamadSleimanHaidar Yes, I would create a new site on Forge for the subdomain the same way you created the site for the domain.

New Site -> Root Domain would be client.mydomain.com

And then in client.mydomain.com site go to SSL -> Let's Encrypt -> Obtain Certificate

Please or to participate in this conversation.