In this tutorial I will learn you how to setup multiple website in Odoo and linking them to multiple (sub)domains. This allows you to setup multiple websites – and webshops – from one shared Odoo database and having those websites run on multiple (sub)domains.
In this tutorial I will setup two websites that link to two subdomains. Let’s assume that you want to have two separate websites where one is an informaton center and one is a shop.
We’ll host the information center on information.yourwebsite.com and the shop on shop.yourinformation.com.
1. Creating multiple websites
The first step in adding an extra website (after the initial one) is by going to Website > Configuration > Settings and clicking on the button “Create a new website”. After clicking on this button you will get a pop-up:

The website name is just informative and will be shown throughout Odoo so give it a good name, such as “Information portal” in our case. The second field, “Website Domain” will tell Odoo to which (sub)domain all pages related to this website should link. Enter the website URL here without www or https:// in front of it and no slashes, so like this:

When this is done click on “Pick a theme”, choose one, save and your second website is set up.
The next step is that you most likely want to configure extra options for your website such as the languages, social media accounts and so on. You can do this from Website > Configuration > Settings again. Keep a close eye out though! The options configured here are website specific! Be sure to first select the website you want to configure at the top before configuring your website further:

Repeat this step for as many websites as you like. Once you’re done it is time for the next step, setting up the DBS records.
2. Setting up the DNS
Now that you’ve setup your website(s) in Odoo it is time to configure the DNS. By configuring the DNS you will tell Odoo that when the user enters a website URL in the web browser (for example www.information.yourwebsite.com) to which server it should connect to get the data from.
Luckily this step is pretty forward. Login to the portal where your DNS is managed – usually your hosting provider – and add an A-record to your DNS list which connects the URL to the IP of the server. Your configuration will look something like this:

3. Configuring NGINX
Alright, so now we’ve told Odoo that we want a website and where it points too and we told our DNS which URL should go to which server (IP). The final step is to tell Nginx (or whichever alternative you use) which domain should link to where. You should already have an Nginx configuration file with a server block. The easiest is to make a duplicate of this block in the existing configuration file. Make sure that this duplicated code block it’s “server_name” points to the domain you’ve setup in the frontend of Odoo (so “information.yourwebsite.com”). Typically it would look something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
server { listen 443 ssl; server_name information.yourwebsite.com; proxy_read_timeout 7200s; proxy_connect_timeout 7200s; proxy_send_timeout 7200s; client_max_body_size 500m; expires $expires; proxy_max_temp_file_size 5924m; # Add Headers for odoo proxy mode proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Client-IP $remote_addr; proxy_set_header HTTP_X_FORWARDED_HOST $remote_addr; # SSL parameters # Make sure that this points to the folder that holds your custom crt and key file ssl_certificate /etc/ssl/your_certificate.crt; ssl_certificate_key /etc/ssl/your_key.key; ssl_session_timeout 30m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'SOME LONG CIPHER HERE'; ssl_prefer_server_ciphers on; # log access_log /var/log/nginx/odoo-dev.access.log; error_log /var/log/nginx/odoo-dev.error.log; # Redirect requests to odoo backend server location / { proxy_redirect off; proxy_pass http://odoo_dev; location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { expires 2d; proxy_pass http://odoo_dev; add_header Cache-Control "public, no-transform"; } } location /longpolling { proxy_pass http://odoo_informationchat_dev; } location /web/static/ { # cash static data proxy_cache_valid 200 60m; proxy_buffering on; # How quick static data expires (and is reloaded on the next request) in seconds expires 864000; proxy_pass http://odoo_information; } } |
That’s it! Just don’t forget to reload and restart your Nginx to apply these changes (sudo service nginx reload and service nginx restart). If you do this configuration you can setup multiple websites with a separate design (theme) running on separate (sub)domains!
4. Conclusion
Thanks to the default built-in features from Odoo setting up multiple websites, webshops or portals is pretty easy! By just creating a second website, adding a DNS records and an Nginx server block you can have a new website running in a matter of minutes!
Has this tutorial helped you, do you have any feedback or questions? Post away!