Implementing Port-Based and DNS-Based Multitenancy in Empress

Introduction

Introduction

Multitenancy is a key feature in Empress, allowing developers to host multiple sites on the same server. This flexibility is critical for businesses looking to streamline their hosting efficiency. The Empress Multitenancy feature is designed to support both Port based and DNS based multitenancy, offering developers the flexibility to choose the approach that best suits their business requirements.

Port-Based Multitenancy

Port-based multitenancy allows you to run each site on a different port. This is useful when you want to isolate different sites for testing or development purposes. Here is a step-by-step guide to implementing port-based multitenancy:

  1. Disable DNS-based multitenancy: This is a one-time operation, executed using the following command:

    bench config dns_multitenant off
    
  2. Create a new site: Use the bench new-site command to initiate a new site, replacing site2name with your desired site name:

    bench new-site site2name
    
  3. Set the port: Assign the new site to run on a specific port. In this example, we’re using port 82:

    bench set-nginx-port site2name 82
    
  4. Generate nginx configuration: This step ensures the new site’s settings are correctly configured in nginx:

    bench setup nginx
    
  5. Reload nginx: Applies the changes by reloading nginx:

    sudo service nginx reload
    

DNS-Based Multitenancy

DNS-based multitenancy allows all sites on a bench to run on the same port. The site that the user accesses is determined by the hostname. This approach is beneficial when hosting multiple sites that share common resources.

Here are the steps to implement DNS-based multitenancy:

  1. Enable DNS-based multitenancy: This is a one-time operation, executed using the following command:

    bench config dns_multitenant on
    
  2. Create a new site: Use the bench new-site command to initiate a new site, replacing site2name with your desired site name:

    bench new-site site2name
    
  3. Generate nginx configuration: This step ensures the new site’s settings are correctly configured in nginx:

    bench setup nginx
    
  4. Reload nginx: Applies the changes by reloading nginx:

    sudo service nginx reload
    

Conclusion

The Multitenancy feature in Empress offers a robust and flexible approach to manage multiple sites. Whether you choose port-based or DNS-based multitenancy, you can efficiently handle multiple sites on a single server, greatly improving your hosting efficiency. By understanding and implementing these techniques, developers can leverage this feature to create and manage complex, multi-site architectures effectively.