Skip to main content

A Step-by-Step Guide to Setting Up a Custom Subdomain for E-commerce Websites

Learn how to set up a custom subdomain for your e-commerce website to improve security and user experience. This guide covers the process of configuring DNS records and setting up a secure subdomain.

Written by Mayank Baswal

Founder of is-cool-me · DNS & Platform Infrastructure

Mayank Baswal maintains the is-cool-me platform and writes technical guides focused on DNS configuration, subdomain infrastructure, SSL troubleshooting, deployment workflows, and platform reliability.

Reviewed by is-cool-me Technical Review
## Introduction Setting up a custom subdomain for e-commerce websites is a crucial step in creating a professional and scalable online presence. A custom subdomain allows developers to organize their applications and services in a logical and structured manner, making it easier to manage and maintain their e-commerce platform. For instance, a developer can set up a subdomain like "shop.myproject.is-pro.dev" for their e-commerce application, while using "api.myproject.is-pro.dev" for their API services. This not only improves the overall user experience but also enhances the security and performance of the platform. In this comprehensive guide, we will walk through the step-by-step process of setting up a custom subdomain for e-commerce websites on the is-cool-me platform. ## Prerequisites Before setting up a custom subdomain, developers need to have a few prerequisites in place. First, they need to have an account on the is-cool-me platform and have created a project with a unique subdomain, such as "myproject.is-pro.dev". They also need to have a basic understanding of DNS records and how they work. Additionally, developers should have a domain name registered with a registrar, such as GoDaddy or Namecheap, and have access to their DNS management panel. It's also recommended to have a basic understanding of SSL/TLS certificates and how to obtain them. For this example, we will assume that the developer has already set up their project on the is-cool-me platform and has a domain name registered with a registrar. ## Step-by-step instructions To set up a custom subdomain for an e-commerce website, follow these step-by-step instructions: 1. Log in to the is-cool-me platform and navigate to the project settings page. 2. Click on the "Subdomains" tab and click the "Add Subdomain" button. 3. Enter the desired subdomain name, such as "shop", and select the project domain, such as "myproject.is-pro.dev". 4. Click the "Create Subdomain" button to create the new subdomain. 5. Log in to the DNS management panel and create a new CNAME record with the following values: * Name: shop * Type: CNAME * Value: myproject.is-pro.dev * TTL: 3600 6. Create a new A record with the following values: * Name: shop * Type: A * Value: 192.0.2.1 * TTL: 3600 7. Run the following command to verify the DNS records: `dig +short shop.myproject.is-pro.dev` 8. Set up an SSL/TLS certificate for the new subdomain using a tool like Let's Encrypt: `certbot certonly --dns-google --dns-google-credentials /path/to/credentials.json -d shop.myproject.is-pro.dev` 9. Configure the web server to use the new SSL/TLS certificate: `sudo nano /etc/nginx/sites-available/shop.myproject.is-pro.dev` 10. Restart the web server to apply the changes: `sudo service nginx restart` ## Configuration deep-dive When setting up a custom subdomain, there are several configuration options to consider. For example, the `api.myproject.is-pro.dev` subdomain may require a different set of DNS records than the `shop.myproject.is-pro.dev` subdomain. The following table compares the DNS records for the two subdomains: | Subdomain | DNS Record | Value | | --- | --- | --- | | shop.myproject.is-pro.dev | CNAME | myproject.is-pro.dev | | shop.myproject.is-pro.dev | A | 192.0.2.1 | | api.myproject.is-pro.dev | CNAME | myproject.is-pro.dev | | api.myproject.is-pro.dev | A | 198.51.100.1 | In addition to DNS records, developers also need to configure their web server to use the new subdomain. For example, the following Nginx configuration file sets up a server block for the `shop.myproject.is-pro.dev` subdomain: ```nginx server { listen 80; server_name shop.myproject.is-pro.dev; root /var/www/shop; index index.html; } ``` Similarly, the following Apache configuration file sets up a virtual host for the `api.myproject.is-pro.dev` subdomain: ```apache ServerName api.myproject.is-pro.dev DocumentRoot /var/www/api Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted ``` ## Common pitfalls and solutions When setting up a custom subdomain, there are several common pitfalls to watch out for. Here are five pitfalls and their solutions: 1. **Incorrect DNS records**: Make sure to create the correct DNS records for the new subdomain. Use a tool like `dig` to verify the DNS records. 2. **SSL/TLS certificate issues**: Make sure to obtain an SSL/TLS certificate for the new subdomain and configure the web server to use it. Use a tool like `certbot` to obtain a certificate. 3. **Web server configuration issues**: Make sure to configure the web server to use the new subdomain. Use a tool like `nginx` or `apache` to configure the web server. 4. **Firewall issues**: Make sure to configure the firewall to allow traffic to the new subdomain. Use a tool like `ufw` to configure the firewall. 5. **Cache issues**: Make sure to clear the cache after setting up the new subdomain. Use a tool like `nginx` or `apache` to clear the cache. ## Best practices To ensure the best performance, security, and maintainability of the custom subdomain, follow these best practices: * Use a secure protocol (HTTPS) to encrypt traffic to the subdomain. * Use a web application firewall (WAF) to protect the subdomain from common web attacks. * Use a content delivery network (CDN) to distribute content and reduce latency. * Use a load balancer to distribute traffic and improve scalability. * Use a monitoring tool to monitor the subdomain and detect issues. ## Troubleshooting section To troubleshoot issues with the custom subdomain, follow these diagnostic steps: 1. Verify the DNS records using a tool like `dig`. 2. Verify the SSL/TLS certificate using a tool like `certbot`. 3. Verify the web server configuration using a tool like `nginx` or `apache`. 4. Verify the firewall configuration using a tool like `ufw`. 5. Verify the cache configuration using a tool like `nginx` or `apache`. Use a tool like `curl` to test the subdomain and detect issues. ## Deployment scenario from operations Here's a complete real-world example of setting up a custom subdomain for an e-commerce website: Let's say we want to set up a custom subdomain for an e-commerce website with the domain name "myproject.is-pro.dev". We want to create a subdomain called "shop" for the e-commerce application. We will use the following DNS records: | Subdomain | DNS Record | Value | | --- | --- | --- | | shop.myproject.is-pro.dev | CNAME | myproject.is-pro.dev | | shop.myproject.is-pro.dev | A | 192.0.2.1 | We will also use the following Nginx configuration file to set up a server block for the subdomain: ```nginx server { listen 80; server_name shop.myproject.is-pro.dev; root /var/www/shop; index index.html; } ``` We will obtain an SSL/TLS certificate for the subdomain using a tool like `certbot` and configure the web server to use it. ## Common mistakes Here are five common mistakes to watch out for when setting up a custom subdomain: * Using incorrect DNS records, such as using an A record instead of a CNAME record. * Failing to obtain an SSL/TLS certificate for the subdomain. * Failing to configure the web server to use the new subdomain. * Failing to clear the cache after setting up the new subdomain. * Failing to monitor the subdomain for issues. ## How to verify it works To verify that the custom subdomain is working correctly, follow these steps: 1. Use a tool like `dig` to verify the DNS records. 2. Use a tool like `certbot` to verify the SSL/TLS certificate. 3. Use a tool like `nginx` or `apache` to verify the web server configuration. 4. Use a tool like `curl` to test the subdomain and detect issues. 5. Use a tool like `google.com` to verify that the subdomain is accessible from outside the network. ## Conclusion with next steps In conclusion, setting up a custom subdomain for an e-commerce website is a crucial step in creating a professional and scalable online presence. By following the step-by-step instructions and best practices outlined in this guide, developers can set up a custom subdomain and ensure the best performance, security, and maintainability of their e-commerce platform. Next steps include monitoring the subdomain for issues, optimizing the web server configuration, and scaling the platform to meet growing demand. ## FAQ Q: What is the difference between a CNAME record and an A record? A: A CNAME record is used to map a subdomain to a canonical name, while an A record is used to map a subdomain to an IP address. For example, a CNAME record might map the subdomain "shop.myproject.is-pro.dev" to the canonical name "myproject.is-pro.dev", while an A record might map the subdomain "shop.myproject.is-pro.dev" to the IP address "192.0.2.1". Q: How do I obtain an SSL/TLS certificate for my custom subdomain? A: You can obtain an SSL/TLS certificate for your custom subdomain using a tool like `certbot`. For example, you can run the following command to obtain a certificate for the subdomain "shop.myproject.is-pro.dev": `certbot certonly --dns-google --dns-google-credentials /path/to/credentials.json -d shop.myproject.is-pro.dev`. Q: How do I configure my web server to use the new subdomain? A: You can configure your web server to use the new subdomain by creating a server block or virtual host for the subdomain. For example, you can create a server block for the subdomain "shop.myproject.is-pro.dev" using the following Nginx configuration file: ```nginx server { listen 80; server_name shop.myproject.is-pro.dev; root /var/www/shop; index index.html; } ``` Q: How do I troubleshoot issues with my custom subdomain? A: You can troubleshoot issues with your custom subdomain by following the diagnostic steps outlined in the troubleshooting section. For example, you can use a tool like `dig` to verify the DNS records, or a tool like `certbot` to verify the SSL/TLS certificate. Q: How do I monitor my custom subdomain for issues? A: You can monitor your custom subdomain for issues using a tool like `google.com` to verify that the subdomain is accessible from outside the network. You can also use a tool like `curl` to test the subdomain and detect issues. Additionally, you can use a monitoring tool like `nginx` or `apache` to monitor the web server configuration and detect issues.
Share this article Share on X Share on LinkedIn
Previous Deploying a Static Website to Free Hosting with a Custom Subdomain: A Tutorial Next Deploying a Static Website to Free Hosting with a Custom Subdomain: A Tutorial