Search code examples
vpsodoo

Multi domains to multi instances


I want to host two odoo instances or database (?), in order to be sure that everything is separated, on a rented VPS for my wife firm and mine. We both have a domain name.

I need the following thing : - Browsing www.mywifedomainname.tld leads to my wife's odoo - Browsing www.myowndomainname.tld leads to my odoo instance

Can you advise me what to do : 1 - Do I need a reverse proxy to have multi domains leading to multi instances ? 2 - In case the reverse proxy is the solution, do you know a good tutorial on how to setup it on Debian (or another distribution) ? 3 - Should I have 2 instances of Odoo or only 2 databases ?

Thanks for you interest :)


Solution

  • yes i have realized this on my server. to achieve that goal I have tested two ways. It's up to you wich one is better to feet on your needs 1 method is odoo+wsgi+appache2 2 method is odoo+nginx+SSL both cases required the proxy reverse. so lest go on. I assume that you know how to install odoo and postgress mandatory requirement:

    1. you should have hardware that can handle odoo postgress and webserver for more than one instance. As of every instance of odoo creates it's own processes. My server (6 core CPU, 3 gb Ram, and i have cpu load around 5% and RAM for 40%, i have 6 different instances rub=ning on this server with different domain names)
    2. for each instance you should have different user created for odoo and for PostgreSQL

    in case of using first method odoo+wsgi+appach you don't ned to configure openerp-server.conf file and sturtuo script as of we gonna use openerp-wsgi.py file as a configuration and the appache to sturt odoo.

    /YOUR_ODOO1_PATH/openerp-wsgi.py modification with your data:


    conf['addons_path'] = 'LINK TO YOUR ODOO1 ADDONS FULL PATH FROM THE ROOT'
    
    admin_passwd = 'ODOO1 MASTR ADMIN PASSWORD'
    
    conf['db_user'] = 'ODOO1_POSTGRESQL_USER_NAME'
    
    conf['db_password'] = 'ODOO1_POSTGRESQL_USER_PASSWORD'
    
    bind = '0.0.0.0:8070'
    
    pidfile = '.gunicorn.pid'
    
    workers = 4
    
    timeout = 240
    
    max_requests = 2000
    
    conf['logfile'] = '/var/log/ODOO1/wsgi-pyton.log'
    

    THAT WILL RUN YOUR ODOO1 instance on port 8070

    for each instance you should use DIFFERENT PORT

    now it is time to configure appache server: I assume that you have installed apache server but in any case, to do that use

    sudo apt-get install apache2
    

    and for mod WSGI

    sudo apt-get install libapache2-mod-wsgi
    
    1. Enable required apache modules:

      sudo a2enmod proxy_http headers rewrite wsgi

    If the system miss some of them you should install this modules first then enable them. More you will find in the Apache website.

    1. Create Configuration file in apache for reverse proxy for site odoo1.com:

      sudo nano /etc/apache2/sites-available/odoo1.conf

    <VirtualHost *:80>
    ServerName odoo1.com
    ErrorLog /var/log/odoo1/openerp-error.log
    CustomLog /var/log/odoo1/openerp-access.log combined
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    ProxyRequests Off
    ProxyPass / **odoo1_full_URL**
    ProxyPassReverse / **odoo1_full_URL**
    ProxyVia On
    LogLevel warn
    </VirtualHost>
    

    odoo1_full_URL replace with http : // odoo1.com: 8070 (for me it is not allowed to post more than 2 url, that way i have write in this way without spaces) 5. Create Site Configuration file to run WSGI script

    sudo nano /etc/apache2/site-available/odoo1-wsgi.conf
    

    With following content

    <VirtualHost *:80>
    ServerName odoo1.com
    WSGIScriptAlias / /YOUR_ODOO1_PATH/openerp-wsgi.py
    WSGIDaemonProcess oe user=ODOO1_USER group=ODOO1_USER processes=2 pythonpath=/YOUR_ODOO1_Path/ display-name=apache-ODOO1USER
    WSGIProcessGroup oe
    ErrorLog /var/log/ODOO1/odoo1-wsgi-error.log
    CustomLog /var/log/ODOO1/odoo1-wsgi-access.log combined
    <Directory /YOUR_ODOO1_PATH>
        Order allow,deny
        Allow from all
    </Directory>
    </VirtualHost>
    
    1. finaly enable your odoo1 and odoo1-wsgi configuration sites and restart apache server

      sudo a2ensite odoo1-wsgi.conf odoo1.conf sudo service apache2 restart

    that's all by typing in the url the odoo1.com you will be able to see your database without port number in the address bar.

    do the same for any other instance and enjoy. Let me know if you will have questions. teh second method I will explain in my next post.