Open nj-dream opened 1 year ago
Hello,
.conf
file. You have 2 options:A. %d
: Odoo extracts the subdomain of a hostname except "www
". Examples: "www.subdomain.domain.tld
" results in Odoo looking for the database name "subdomain
". "subdomain.domain.tld
" results in Odoo looking for the same database name "subdomain
". "www.domain.tld
" results in Odoo looking for the database name "domain
".
B. %h
: Odoo takes the full domain name. Examples: "www.subdomain.domain.tld
" results in Odoo looking for the database name "www-subdomain-domain-tld
". "subdomain.domain.tld
" results in Odoo looking for the database name "subdomain-domain-tld
", and so on.
%d
or %h
are regex expressions. In my setup I use dbfilter = ^%d$
.
location / {
proxy_pass http://my_odoo_IP_address:port;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
If it isn't possible to match database names from the host/domain name, you can use the module db_filter_from_header
to do this for you, without you having to add any of the above configuration lines into the odoo .conf
file and nginx
.conf
file.
Thank you so much for your talking the time to respond to my question. Your answer was incredibly helpful and I really appreciate it.
@nj-dream Happy to solve this issue. In your case, what exactly was the precise cause of your issue? Which solution did you use?
I have installed an Odoo16 instance using your script. The domain name is a.mydomain.com and the database is 'a'. Now I want to add another domain name, b.mydomain.com, with a separate database 'b'. I would like to use different subdomains to access different Odoo instances with different databases.
My server environment is Ubuntu 22.04 with SSL enabled. I first copied the nginx configuration file for a.mydomain.com and replaced all instances of a.mydomain.com with b.mydomain.com in the new configuration file. Then I ran 'sudo ln -s /etc/nginx/sites-available/b.mydomain.com /etc/nginx/sites-enabled/b.mydomain.com' and used 'sudo certbot --nginx -d b.mydomain.com --noninteractive --agree-tos --email admin@mydomain.com --redirect' to create an SSL certificate.
I then used Odoo's database management function to create a new database named 'b'. Next, I modified the 'odoo.conf' configuration file by adding 'dbfilter = ^%d$'. Finally, I restarted Odoo and nginx.
When I visit a.mydomain.com, I see the Odoo login page for the 'b' database, and when I visit b.mydomain.com, I see the Odoo database selection page.
What did I do wrong and how can I access the correct Odoo database based on the subdomain name? Thank you!"