Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
12 Risposte
16849 Visualizzazioni

Hi !


Given the standard multi-db configuration:

# wildcard proxy for odoo:
# one subdomain -> one database

<VirtualHost *:80>
 ServerName mydomain.fr
 ServerAlias *.mydomain.fr

 ErrorLog /var/log/odoo/odoo-error.log
 CustomLog /var/log/odoo/odoo-access.log combined
 LogLevel warn

 <Proxy *>
  Order deny,allow
  Allow from all
 </Proxy>

 ProxyRequests Off
 ProxyPass / http://mydomain.fr:8089/
 ProxyPassReverse / http://mydomain.fr:8089/

 ProxyVia On
</VirtualHost>

So I already know how to serve database 'foo' with url http://foo.mydomain.com.

In my Odoo config, the dbfilter is set to ^%d$.

How one would add a domain which point to a specific database ?

Example:

  • user access to http://bar.com/web/login

  • apache proxies to http://quz.mydomain.fr/web/login

  • then the config already in place do its job like for other databases: proxy to http://mydomain.fr:8089/ with previous url given to Odoo, so that it serves the db matching the subdomain (here database_of_another_domain)

Avatar
Abbandona
Autore Risposta migliore

Finally, I came up with this:

################
# welcome page #
################

<VirtualHost *:80>
    ServerName mydomain.fr
    ServerAlias www.mydomain.fr
    DocumentRoot /var/www/odoo
</VirtualHost>


#################
# wilcard proxy #
#################

<VirtualHost *:80>
    ServerName mydomain.fr
    ServerAlias *.mydomain.fr

    ErrorLog /var/log/odoo/odoo-error.log
    CustomLog /var/log/odoo/odoo-access.log combined
    LogLevel warn

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://mydomain.fr:8089/
    ProxyPassReverse / http://mydomain.fr:8089/

    ProxyVia On
</VirtualHost>


##################
# customer proxy #
##################

<VirtualHost *:80>
    ServerName other-domain.com
    ServerAlias www.other-domain.com

    ProxyRequests Off
    ProxyPass / http://other-domain.mydomain.fr/
    ProxyPassReverse / http://other-domain.mydomain.fr/

    ProxyVia On
</VirtualHost>


################
# restrictions #
################

<Location /web/database>
    Order deny,allow
    Deny from all
    Allow from 1.2.3.4
    Allow from 5.6.7.8
</Location>

Thanks to you, Ermin Travisan for your help.

Avatar
Abbandona
Risposta migliore

1. Use the dbfilter parameter in the openerp-server.conf file. You have 2 options:

- %d: Odoo extracts the subdomain of a hostname except of "www". Examples: "www.subdomain.domain.tld" results in the database name "subdomain". "subdomain.domain.tld" results i the same database name "subdomain". "www.domain.tld" results in the database name "domain"!

- %h: Odoo takes the FQDN. Examples: "www.subdomain.domain.tld" results in the database name "www-subdomain-domain-tld". "subdomain.domain.tld" results in "subdomain-domain-tld" and so on.

%d or %h are regex expressions, in my setup I use dbfilter = ^%d$.

2. In your Apache vhost definition proxy to the IP address and port of your Odoo server and forward the request headers:

You can either use the directive "ProxyReserveHost" or the options X-Forwarded-For (see http://stackoverflow.com/questions/6070335/retain-original-request-url-on-mod-proxy-redirect)  

If it is not possible to match database names from the host/domain name, you can use the module https://www.odoo.com/apps/modules/9.0/dbfilter_from_header/


Avatar
Abbandona
Autore

I already know about the dbfilter, and all that works perfectly.

What I miss, is how to proxy from "bar.com/web" to "quz.mydomain.fr/web", so that "quz.mydomain.fr/web" gets in turn proxied to "mydomain.fr:8069/web" by the already in place configuration.

What is the name of the database you want to connect to? Is it "bar" or "quz"? I'm not sure if it has to be that complicated. Anyway, with a proper rewrite you should be able to achieve your goal.

Autore

The database is "quz", and "bar.com" is the domain that should be visible.

See my amended answer.

Autore

So, it isn't possible, on a single Odoo (8.0 by the way, forgot to mention) instance, to :

- proxy "foo.mydomain.fr", "xyz.mydomain.fr" to "mydomain.fr:8069" with respectively databses "foo" and "xyz" ;

- proxy "bar.com" to "mydomain.fr:8069" with database "quz" (can be anything, really) with or without the intermediate proxy "quz.mydomain.fr"

?

The first one is for sure easily possible, because that's the common dbfilter use case. The second one might be possible with proper URL rewriting. But I do not understand why you don't want to name the database "bar" instead of "quz" in the first place.

Autore

It's just an example. In fact it is the same. But since the config file allow only one dbfilter, it doesn't really matter.

Or does it ? Can a dbfilter have an OR condition ? Like: ^%d$ | ^%h$

The result of the dbfilter operation should match a single database which would not be the case in your example.

Autore

Thanks for your help. I'll try some rewrite rules and all that good stuff then.

Post correlati Risposte Visualizzazioni Attività
0
mag 15
4311
1
apr 16
5160
0
mar 25
449
0
gen 25
2656
1
ago 23
13539