Automatically choose database based on subdomain

Timo Goosen

I'm using Odoo + Nginx as a reverse SSL proxy. I followed this guide to get it setup:


I'd like to type in and have it redirected to the login page for that given database.  In the background this should be happening:

When I request:

This should be returned

And in the background I would like this to happen:


On OpenERP 7 + Apache2 I know how to set this up , but I'm not sure how to do this with Nginx.


Someone refered me this guide but is not helping much:


Hope you understand my question.  Your help would be much appreciated.

1 Answer
Best Answer

I think your problem is due to the following: with the most common nginx reverse proxy I've seen on the web, all https requests for subdomains are forwarded to the same server:



that is the domain that reaches dbfilter!!

The solution I found was:

  • Add dbfilter=%d to your config file. I have tried several other options like ^%d$, and this is the only one that worked!
  • restart odoo
  • Then, for each subdomain you want to add:
    • Configure your dns so that it points to the right ip
    • Add a line to /etc/hosts with
    • subdomain.localhost
    • Create a new site in nginx with server_name that does a proxy_pass to http://subdomain.localhost:8069
    • restart nginx
    • create the database whose name is *exactly* subdomain
1 Comment
Lalit Sharma

Hi, I tried that but that didn't work. Can you please help where I can check the issue is?