dbfilter doesn't work in proxy configurations

Bug #1065127 reported by The Loeki
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Medium
OpenERP's Framework R&D

Bug Description

First reported in https://bugs.launchpad.net/openobject-server/+bug/940439/comments/6 by Alvar V. (alvar-vilu), but it's actually a different bug than the one discussed there:

When OpenERP (at least 6.1+) is deployed behind a proxy, the dbfilter option won't work.

This is due to openerp/addons/web/controllers/main.py (lines 136+) doing:

def db_list(req):
    dbs = []
    proxy = req.session.proxy("db")
    dbs = proxy.list()
    h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
    d = h.split('.')[0]
    r = req.config.dbfilter.replace('%h', h).replace('%d', d)
    dbs = [i for i in dbs if re.match(r, i)]
    return dbs

However, in proxy configs, it should user HTTP_X_FORWARDED_HOST as filter.

This can easily be done by checking whether that var is in the environ:

def db_list(req):
    dbs = []
    proxy = req.session.proxy("db")
    dbs = proxy.list()
    if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
        h = 'HTTP_X_FORWARDED_HOST'
    else:
        h = 'HTTP_HOST'
    h = req.httprequest.environ[h].split(':')[0]
    d = h.split('.')[0]
    r = req.config.dbfilter.replace('%h', h).replace('%d', d)
    dbs = [i for i in dbs if re.match(r, i)]
    return dbs

Tags: dbfilter proxy
The Loeki (the-loeki)
Changed in openobject-server:
status: New → Confirmed
description: updated
description: updated
tags: added: proxy
description: updated
Revision history for this message
hiren (hiren-6) wrote :

Hi,

is this a major issue out there? We are moving to use db-filter so I'm wondering if this is a problem with a recent openerp 7.0 nightly build?

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Medium
Revision history for this message
Niels Huylebroeck (red15) wrote :

Recent code should not require this, as the generic setting in config 'proxy_mode' does all the wrapping of X-HTTP-Forwarded-Host onto the regular host.

Can you try with enabling the proxy_mode = True in config file ? (You can also pass argument --proxy-mode to enable it)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.