How To Use Apache as Reverse Proxy on Odoo

By | November 8, 2015

Hello,

Odoo currently is very wellknown ERP that everybody can use it freely. On default Odoo use port 8069 (ex www.example.com:8069) to access the application. But we can remove those port by using Apache as a reverse proxy. This tutorial consider that Odoo has been installed on the server.

Install Apache2 and enable some modules

sudo apt-get install apache2
sudo a2enmod proxy_http headers rewrite

Create self-signed certificate (optional)

openssl genrsa -out privkey.pem 2048
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

Copy created file to the SSL directory => /etc/ssl/odoo/

Create a new apache2 configuration file

sudo nano /etc/apache2/site-available/odoo.example.com <== please change this as your own address

Fill the file with this code (NO SSL)

    
        ServerName domain.com // <== CHANGE THIS VALUE
        ServerAlias *.domain.com // <== CHANGE THIS VALUE
        ErrorLog /var/log/openerp/openerp-error.log <== CHANGE THIS VALUE
        CustomLog /var/log/openerp/openerp-access.log combined <== CHANGE THIS VALUE
        
            Order deny,allow
            Allow from all
        
        ProxyRequests Off
        ProxyPass / http://127.0.0.1:8069/
        ProxyPassReverse / http://127.0.0.1:8069/
        ProxyVia On
        LogLevel warn
    

Fill the file with this code (WITH SSL)


ServerName office.serayamotor.com
ServerAdmin [email protected]

    Redirect permanent / https://odoo.example.com/ // <== CHANGE THIS VALUE
    TransferLog /var/log/apache2/transfer.erp.your-domain.at.log



   ServerName odoo.example.com // <== CHANGE THIS VALUE
   ServerAdmin [email protected]  // <== CHANGE THIS VALUE

   
        Order deny,allow
        Allow from all
   
   ProxyRequests Off
   SSLProxyEngine on
   SSLEngine on
   SSLCertificateFile /etc/ssl/odoo/cacert.pem
   SSLCertificateKeyFile /etc/ssl/odoo/privkey.pem
   SSLCACertificateFile /etc/ssl/odoo/cacert.pem
   RequestHeader set "X-Forwarded-Proto" "https"
   SetEnv proxy-nokeepalive 1
        ProxyPass / http://127.0.0.1:8069/
        ProxyPassReverse / http://127.0.0.1:8069/
   ProxyErrorOverride off
   TransferLog /var/log/apache2/transfer.erp.your-domain.at.log
   #Fix IE problem (httpapache proxy dav error 408/409)
   SetEnv proxy-nokeepalive 1

Make the file symlinks to sites-enable directory

sudo ln -s /etc/apache2/sites-available/odoo.example.com.conf /etc/apache2/sites-enabled/odoo.example.com.conf

To disable Odoo on port 8069, please add 127.0.0.1 value on xmlrpc-interface= and netrcp-interface= located at

/etc/odoo/openerp-server.conf

Restart the apache and it should works.

Have fun..