I wanted one Odoo server to handle multiple low traffic sites on different domains. Because multi-company is not well supported in the Community version (either it doesn't work or is not clearly documented), the best I could do was run Odoo against multiple databases, one for each domain. I wanted the setup as simple as possible and with luck I found a way that doesn't require modifying source code (changing h.partition in "http.py") or setting up Apache as a proxy.
Here is how:
Install Odoo as you normally would.
Using iptables ("iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8069") point 8069 to 80 (if you are using UFW - make sure to open both ports! - "ufw allow 8069", and add the iptables line to /etc/rc.local to make it stick around after a reboot)
Create the databases for your domains, but the database name *has* to take the form of "<domainname>_<TLD>", for example "yourdomain.com" should have a database named "yourdomain_com" with an underscore between the domain name and TLD. If you try to use a dash instead of an underline, Odoo says it is not an allowed character, which must have been a change with v10 because everywhere else said use a dash.
Then edit "/etc/odoo/odoo.conf" and add "dbfilter = %h" (I did it before the addons_path, but I don't think it matters) There is endless documentation for using "%d" for subdomains, but very little for domains.
Restart Odoo ("service odoo restart")
Point your domain A records at Odoo and each site will then pick up it's respective database.
You can actually do all this in reverse and it will still work, i.e. add dbfilter to odoo.conf, then visit each domain and create their respective databases (still appropriately named with underscores) for each domain.
A few caveats:
You will notice that if you go to the database manager, it will only show you the database for the current domain, i.e. if you have two databases, one "myfirstdomain_com" and "mysecondomain_org", if you visit /web/database/manager from myfirstdomain.com, you will only see the myfirstdomain_com database. The "mysecondomain_org" will be hidden. You also can't fool Odoo by going to the database selector with an IP address, the only way to manage all the databases at once is to comment out the "dbfilter" code in odoo.conf.
The domain must remove the "www" otherwise, it will fail.
If you messed something up, you will get the database creation page popping back up.
It took me most of the day, but I figured it out with a lot of googling and just trying random things. Someone else might as well save the hours if it takes me a half hour to document it.
Sean.
Nice work.
Good job!!!