This question has been flagged
4 Replies
18576 Views

I have in my conf file:

dbfilter=^%d$

which works perfectly fine, it uses different databases based on the subdomain. Would it be possible to write an IF statement or a configuration where some subdomains use the same database? For example:

I want that site1.example.com use database site1

site2.example.com use database site2

and example.com use database site2.

Is it possible for some domains to have the same database? Or just use the multi-website module?

Avatar
Discard
Best Answer

Did you notice that you're trying to serve TWO different websites with just ONE same database? How's that even possible? And if feasible, why would you try to launch such a mess? What's the benefit in the end? Both would carry the exact same data and settings (hint: ONE DATABASE)

database2 with website1

database2 with website2

That's like sending TWO salespeople to two different cities, but both have to be riding in the same car, at the same time.

Avatar
Discard
Best Answer

By default, this is not possible. There are 2 workarounds:

- with your dbfilter setting, "example.com" and "example.example.com" would both point to the database "example"

or

- you use the module "dbfilter_from_header" instead of the dbfilter parameter and then you specify the database for each hostname separately.

This has nothing to do with the multi-website module.

Avatar
Discard
Author

That is actually what I need, I tried using it, but somehow it didn't work as expected. I am trying to use also the multi website module. The error I am getting is that the URL is not correct.

So basically it would be that:

domain1. example.com having the database1

example.com having database2 with website1

domain2.example.com with database2 with website2

I want to have one database with two different websites. I am using Odoo 12 and it's behind an nginx reverse proxy, the config for the domain2 website is this:

# Odoo servers

upstream odoo {

server 192.168.100.10:8069;

}

upstream odoochat {

server 192.168.100.10:8072;

}

server {

listen 80;

server_name domain2.example.com;

include snippets/letsencrypt.conf;

return 301 https://domain2.example.com$request_uri;

}

server {

listen 80;

server_name example.com;

include snippets/letsencrypt.conf;

return 301 https://example.com$request_uri;

}

server {

listen 443 ssl http2;

server_name domain2.example.com example.com;

proxy_read_timeout 720s;

proxy_connect_timeout 720s;

proxy_send_timeout 720s;

# Proxy headers

proxy_set_header X-Forwarded-Host $host;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Real-IP $remote_addr;

# proxy_set_header X-Odoo-dbfilter ^database2\Z;

# SSL parameters

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;

include snippets/ssl.conf;

# log files

access_log /var/log/nginx/odoo.access.log;

error_log /var/log/nginx/odoo.error.log;

# Handle longpoll requests

location /longpolling {

proxy_pass http://odoochat;

}

# Handle / requests

location / {

proxy_redirect off;

proxy_pass http://odoo;

}

# Cache static files

location ~* /web/static/ {

proxy_cache_valid 200 90m;

proxy_buffering on;

expires 864000;

proxy_pass http://odoo;

}

# Gzip

gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;

gzip on;

}

Another error is I added to the odoo.conf

server_wide_modules = "web, dbfilter_from_header"

but it says it doesn't exists, I have them copied in the addons folder of odoo with the owner odoo:odoo.

I appreciate your help.

The module is not ported to Odoo 12.0 yet.