diff --git a/slapos/recipe/apache_frontend/__init__.py b/slapos/recipe/apache_frontend/__init__.py
index 413933da6428465dc6fefe12ef35bff19ee30555..0a9e16f28a32caf6964c06d1cbe033d649a930c0 100644
--- a/slapos/recipe/apache_frontend/__init__.py
+++ b/slapos/recipe/apache_frontend/__init__.py
@@ -88,8 +88,11 @@ class Recipe(BaseSlapRecipe):
 
       # Check for custom domain (like mypersonaldomain.com)
       # If no custom domain, use generated one.
-      domain = slave_instance.get('custom_domain', 
-          "%s.%s" % (reference.replace("-", "").lower(), frontend_domain_name))
+      # Note: if we get an empty custom_domain parameter, we ignore it
+      domain = slave_instance.get('custom_domain').strip()
+      if domain is None or domain == '':
+        domain = "%s.%s" % (reference.replace("-", "").lower(),
+            frontend_domain_name)
       # Define the URL where the instance will be available
       # WARNING: we use default ports (443, 80) here.
       slave_dict[reference] = "%s%s/" % (scheme, domain)