Configuring Odoo SaaS and Odoo.sh to work with a naked domain (e.g., domain.com without the 'www') isn't supported out of the box. This setup requires a bit of workaround using third-party DNS services and setting up redirections to ensure both secure (https) and non-secure (http) traffic from your naked domain correctly redirects to the 'www' version of your site. In this article, we'll guide you through the necessary steps to achieve this configuration.
Understanding the challenge
By default, Odoo SaaS and Odoo.sh expects domains to be configured with a subdomain, typically 'www'. However, many businesses prefer to use a naked domain for branding or simplicity. This preference necessitates a workaround since direct A or AAAA DNS records pointing to Odoo.sh IPs can lead to issues, especially with SSL certification.
Step 1: Choose a third-party DNS service
First, you'll need a third-party DNS service that supports URL redirections, such as Cloudflare, DNSimple, or Namecheap. These services offer URL forwarding or HTTP redirection features, which are crucial for our setup.
We will use Cloudflare as an example for the DNS configuration and setting up the redirection of the naked domain.
Step 2: Configure the DNS settings
- Point your 'www' subdomain to Odoo.sh:
- Create a CNAME record for 'www' pointing to your Odoo.sh project domain (e.g., myproject.odoo.com).
- Set up redirection for the naked domain:
- Use your DNS provider's URL forwarding or redirection feature to redirect traffic from your naked domain (domain.com) to your full domain (www.domain.com). Ensure you set this up for both HTTP and HTTPS protocols.
Step 3: Implement a redirection
While the exact steps can vary depending on your DNS provider, the general idea remains the same:
- For HTTP: Set up a URL forwarding or redirection rule where any traffic coming to http://domain.com is redirected to http://www.domain.com.
- For HTTPS: This can be more complex due to SSL certificate requirements for the naked domain. You might need to utilize a service within your DNS provider that offers SSL for the redirection service or a dedicated SSL certificate for the naked domain just to handle the redirect.
With Cloudflare, you need to create a new page rule to redirect your domain.com/* requests to https://www.domain.com/$1 with a 301 status code (permanent redirect).
Step 4: Test your setup
After configuring the DNS and redirection settings, it's crucial to test your setup:
- Access your naked domain (http://domain.com and https://domain.com) in a web browser and ensure it redirects to the 'www' version.
- Use online tools like SSL Labs (for SSL redirection) or DNSChecker to verify that your DNS settings propagate correctly.
Conclusion
Configuring a naked domain with Odoo requires a few extra steps and the assistance of a third-party DNS service, but it's certainly achievable. This setup ensures your Odoo SaaS service or Odoo.sh platform is accessible via a cleaner, more brand-friendly URL, enhancing your professional image.
Remember, the exact steps may vary slightly depending on your chosen DNS service, so refer to their documentation for specific instructions related to redirection and SSL configuration.