Thursday 12 July 2012

Running Multiple OpenERP Server on proxy on different port.

Create two proxy configuration as follow in user defined file like here i have created web-client61

<VirtualHost *:80>
    ServerName webclient6
    ServerAdmin webmaster@localhost
    LimitRequestLine 16384

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

    ProxyRequests Off
    ProxyPass / http://127.0.0.1:8069/
    ProxyPassReverse / http://127.0.0.1:8069/
    SetEnv proxy-nokeepalive 1
    ErrorLog /var/log/apache2/webclient-error.log
    CustomLog /var/log/apache2/webclient-access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName webclient67
    ServerAdmin webmaster@localhost
    LimitRequestLine 16384

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

    ProxyRequests Off
    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/
    SetEnv proxy-nokeepalive 1
    ErrorLog /var/log/apache2/webclient-error.log
    CustomLog /var/log/apache2/webclient-access.log combined
</VirtualHost>

Now add this two server name as a domain in /etc/hosts
Your IP domain(webclient1)

Now enable this webclient61 file for apache using following command.

sudo a2ensite webclient61

The above command will enable the file webclient61, hence the configuration will be available to apache.

Now restart the apache with init.d and run your two servers on different port, and run the URL web-client1 and web-client2, this way you can access two different OpenERP server in same browser's two different tab.

Purpose of doing this.

If you run two server on different port and login with your webclient localhost:8069 so automatically you will be loggedin to localhost:8000 because the session id for domain localhost is already set in cookies, so when your just type localhost:8000 in which you still not logged, so you will be redirected to home page because when you send a request for localhost:8000 so browser will look up in cookies for domain localhost browser never take port into account, so it will find session_id in cookies for the domain localhost and will show you logged in.

Yes we can set cookies for specific patch using set_cookies path, but  in web-client when we send a request from localhost:8000 so it's request path will be "/" so the cookies are set for the path "/"

So I did't found any other way to fix this but using proxy we can have an alternative way to use two server on different port with different domain name, so for two different domain two different cookies are set.

For further information about cookies see the post 
http://mishekha.blogspot.in/2012/07/cookies.html

And for Apache reverse proxy for OpenERP see the post http://mishekha.blogspot.in/2011/11/connect-openerp-using-reverseproxy.html

Thanks & Regards,
Mohammed Shekha.

No comments:

Post a Comment