Odoo Help

Welcome!

This community 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.

1

Subdomain filtering databases does not work

By
Andrius Laukavičius
on 10/10/14, 6:47 AM 1,917 views

I'm trying to configure domain in a way, so I could use subdomain for accessing database. For example if my domain is `domain.com` and I have databases `demo` and `demo2`. Then I should be able to access it by writing `demo.domain.com` and `demo2.domain.com`. But none of this work. I followed this guide: http://opensourceholic.com/2014/05/09/deploy-openerp-using-mod_proxy-and-mod_wsgi-on-linux-server/

After doing everything by the guide, what I was able to do, was I can only access Odoo web by writing `domain.com`, but if I write `demo.domain.com`, I will only get this message `This webpage is not available`.

So what I did:

My apache2 configuration files:

`openerp.conf`

    <VirtualHost *:80>
        ServerName domain.com
        ServerAlias *.domain.com // 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
        </Proxy>
        ProxyRequests Off
        ProxyPass / http://domain.com:8069/
        ProxyPassReverse / http://domain.com:8069/
        ProxyVia On
        LogLevel warn
    </VirtualHost>

`openerp-wsgi.conf`:

    <VirtualHost *:80>
        ServerName domain.com
        ServerAlias *.domain.com // Use this if you want dbfillter on subdomain
        WSGIScriptAlias / /opt/openerp/server/openerp-wsgi.py
        WSGIDaemonProcess oe user=user group=oerp processes=2 python-path=/opt/openerp/server/ display-name=apache-openerp
        WSGIProcessGroup oe
        ErrorLog /var/log/openerp/openerp-error.log
        CustomLog /var/log/openerp/openerp-access.log combined
        <Directory /opt/openerp/server>
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>

My `openerp-wsgi.py` configuration:

    import openerp
    
    #----------------------------------------------------------
    # Common
    #----------------------------------------------------------
    openerp.multi_process = True # Nah!
    
    # Equivalent of --load command-line option
    openerp.conf.server_wide_modules = ['web']
    conf = openerp.tools.config
    
    # Path to the OpenERP Addons repository (comma-separated for
    # multiple locations)
    
    conf['addons_path'] = '/opt/openerp/server/addons/,/opt/openerp/server/openerp/addons/'
    
    # Optional database config if not using local socket
    #conf['db_name'] = 'demo'
    conf['db_host'] = '127.0.0.1'
    conf['db_user'] = 'user'
    conf['db_port'] = 5433
    conf['db_password'] = 'password'
    #conf['dbfilter'] = '%d'
    #----------------------------------------------------------
    # Generic WSGI handlers application
    #----------------------------------------------------------
    application = openerp.service.wsgi_server.application
    
    openerp.service.server.load_server_wide_modules()
    
    #----------------------------------------------------------
    # Gunicorn
    #----------------------------------------------------------
    # Standard OpenERP XML-RPC port is 8069
    bind = '0.0.0.0:8069'
    pidfile = '.gunicorn.pid'
    workers = 4
    timeout = 240
    max_requests = 2000

And even after doing this, it still was not working, so I added this line in /etc/hosts:

`127.0.0.1 domain.com` Then I was able to access OpenERP when entering domain.com address, but only this. If I add suggested filter (either directly in config file or in openerp-wsgi.py file), then system does not find any database and I can't access any of it, even in the list not to mention the main reason I'm doing this to access by subdomain (as written in an example).

So what is wrong here?

Note. I'm trying this on Odoo v8. 

1
Andrius Laukavičius
On 10/10/14, 8:24 AM

I figured I need to manually enter every subdomain in /etc/hosts, only then it starts working I expect.

7

swapnil wagh

--swapnil wagh--
1559
| 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/11/14, 3:39 AM

Hi Andrius Laukavičius,

If you are working on local machine you should edit /etc/hosts with something like this:

127.0.0.1 foo.localhost

127.0.0.1 bar.localhost

where foo and bar are the db names.

Your virtual host file should look like this:

<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

</Proxy>

ProxyRequests Off

ProxyPass / http://localhost:8069/

ProxyPassReverse / http://localhost:8069/

ProxyVia On

LogLevel warn

</VirtualHost>

After that  write dbfilter = ^%d$ in your openerp/tools/config.py file. After that restart apache2 and openerp.

In case you are doing all this on VPS and you bough a domain from domian provider, then you dont need to edit /etc/hosts file.

 

0
Andrius Laukavičius
On 10/10/14, 8:24 AM

I figured I need to manually enter every subdomain in /etc/hosts, only then it starts working I expect.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/10/14, 6:47 AM
Seen: 1917 times
Last updated: 3/16/15, 8:10 AM