Implementing Multiple Custom Domains and SSL Configuration in Empress

Introduction

Welcome, developers! In Empress, we have a versatile feature named Multiple Custom Domains, a must-know for those aiming to expand their website’s reach or add an additional layer of security through SSL. This guide will guide you through the process of adding multiple custom domains and setting up SSL for those domains.

Using the Add-Domain Command

To add a custom domain for your site, Empress provides the add-domain command. Simply run:

bench setup add-domain [desired-domain]

Upon running this command, the system will prompt you for the site that the custom domain will be allocated to.

Setting Up SSL

Empress also supports SSL setup for your custom domains. To achieve this, use the --ssl-certificate and --ssl-certificate-key options as follows:

--ssl-certificate [path-to-certificate]
--ssl-certificate-key [path-to-certificate-key]

Here’s an example of how to use these options:

bench setup add-domain custom.erpnext.com --ssl-certificate /etc/letsencrypt/live/erpnext.cert --ssl-certificate-key /etc/letsencrypt/live/erpnext.key

This command will set up SSL for the domain custom.erpnext.com using the specified SSL certificate and key.

Domain Configuration Storage

Domain configurations in Empress are stored in the site_config.json file of the respective site. An example of what the configuration may look like is shown below:

 "domains": [
  {
   "ssl_certificate": "/etc/letsencrypt/live/erpnext.cert",
   "domain": "erpnext.com",
   "ssl_certificate_key": "/etc/letsencrypt/live/erpnext.key"
  }
 ],

Putting Your Custom Domain into Effect

Once you’ve set up your custom domain, you’ll need to regenerate the nginx configuration and reload the nginx service to put your custom domain into effect. This can be done by running the following commands:

bench setup nginx
sudo service nginx reload

Conclusion

The Multiple Custom Domains feature is a powerful tool in Empress, allowing developers to increase their site’s visibility and apply important security measures. This guide should give you a clear understanding of how to effectively add multiple custom domains and set up SSL for those domains. With this knowledge, you can customize and extend your Empress applications to suit your business needs.