Odoo Help


How to setup apache2 and openerp to match subdomains with databases ?

on 10/2/14, 4:44 AM 3,496 views

Hello there !

First of all, I'm kind of new to virtual hosts and redirecting urls.

I am trying to setup apache to redirect a subdomain to a matching openerp database on my server. Example: http://foo.mydomain.com will call the database foo.

I'm testing with localhost, so I edited /etc/hosts with something like this: foo.localhost bar.localhost

Here is my virtual host declaration in /etc/apache2/sites-available/openerp.conf:

<VirtualHost *:80>
    ServerName localhost
    ServerAlias *.localhost // Use this if you want dbfillter on subdomain
    ErrorLog /var/log/openerp/openerp-error.log
    CustomLog /var/log/openerp/openerp-access.log combined
    <Proxy *>
        Order deny,allow
        Allow from all
    ProxyRequests Off
    ProxyPass / http://localhost:8069/
    ProxyPassReverse / http://localhost:8069/
    ProxyVia On
    LogLevel warn

After that, I wrote dbfilter = ^%d$ in my openerp.conf file. After apache2 and openerp were restarted, I started testing it.

The thing is, the first time I try to reach a new database, I have to explicitely write http://database-name.localhost?db=name-of-the-new-db. After the first login/logout, I just have to type http://database-name.localhost, as expected. I'm not sure if I have to do it on all computers (no tested yet) but it's kinda weird I think.

Is it part of openrp mechanism to bound a subdomain to a database, or just a bug, or something I've done wrong ?


(my edit was a clarification one)

No one ?


swapnil wagh

--swapnil wagh--
| 6 5 8
Pune, India
--swapnil wagh--

My name is Swapnil A. Wagh. I studied Master Of computer Science and work as a Software Engineer. I’m a technology enthusiast and always eager to learn new and exciting technologies. I’m constantly looking for innovative solutions to age-old problems that push the limits of what we conceive to be possible.

swapnil wagh
On 10/14/14, 11:48 AM

Check this for your answer https://www.odoo.com/forum/help-1/question/how-to-set-database-filter-on-sub-domain-for-odoo-website-using-apache-web-server-64935#answer-65100

Thanks, I'll have a look at this !

on 10/15/14, 3:41 AM

This is exactly what I have in my config files... But I still have to write subdomain.localhost/?db=subdomain the first time for each new database. The second time and later, I just need subdomain.localhost, and it will write the ?db= part itself.

on 10/15/14, 3:47 AM
Carlton Guc
On 5/19/15, 12:43 PM

Here is a complete write up of how we implement Apache to redirect urls to databases.


Hengky Zhang
On 10/10/14, 1:08 PM

maybe you can use port redirect in apache vhost instead of using your method

becoz i use port redirect for my case

maybe you can try my conf

<VirtualHost *:80>

ServerName mydomain.com

Redirect 8069 / http://mydomain.com:8069/


This is exactly what I'm doing, I think. But perhaps you can share your conf files ? :)

on 10/14/14, 5:36 AM
servername a.b.com redeirect / http://a.b.com:8069
Hengky Zhang
on 10/14/14, 5:52 AM

I tried this way, but it's very tedious, as you'll have to create one virtual host entry for each subdomain.

on 10/14/14, 6:02 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 10/2/14, 4:44 AM
Seen: 3496 times
Last updated: 5/19/15, 12:43 PM