Configure Apache Web Server with Odoo

blog-banner

Odoo is very well known ERP system today. Odoo 9 provides great features that will help to grow business. By default odoo runs over port 8069. So we are accessing server using domain:8069. What if we need to access server using only domain like a standard website? We can do it by configuring web server with odoo. Here I am going to show you configuration of Apache web server for odoo.

Before configuring apache with odoo, first check whether apache web server is installed on your machine or not. If not installed then execute below command to installed it.

sudo apt-get update

sudo apt-get install apache2

After installing apache on your machine, you need to enable some modes by executing below commands.

sudo a2enmod proxy proxy_http

Now go to the directory, “/etc/apache2/sites-available” and create a file with <domain-name>.conf.  Here I am going to use “demo.surekhatech.com” domain for my odoo server. So the file name will be “demo.surekhatech.conf”. Add the below content into this file.

	<VirtualHost *:80>
		ServerName demo.surekhatech.com
		ServerAlias demo.surekhatech.com
	
		LogLevel warn
		ErrorLog /var/log/apache2/demo.surekhatech.com.error.log
		CustomLog /var/log/apache2/demo.surekhatech.com.access.log combined
	
		ProxyPass / http://localhost:8069/
		ProxyPassReverse / http://localhost:8069/
	</VirtualHost>

After adding the virtual host for odoo server, you need to enable site using the following command.

sudo a2ensite demo.surekhatech.conf

A message will appear showing that site is enabled. After that you need to restart the apache server by executing below command.

sudo service apache2 restart

Make the host file entry in case you have made the configuration on the local machine. Open the “hosts” file by executing below command:

sudo nano /etc/hosts

Add the following entry into this file.

127.0.0.1 demo.surekhatech.com

After completing with above configuration, you can access the odoo server by hitting the “demo.surekhatech.com” in any browser. You can see that the odoo server is running over the “http”. But what if we need to run our odoo server over more secure channel i.e. “https”.

For that you need SSL certificate and key. You can buy the certificate from any trusted vendor. You can also generate certificates and used it. Certificate can be generated using the openssl toolkit. For linux machine you can generate certificate by using the following commands.

To generate key:

openssl genrsa -out demo.surekhatech.com.key 2048

To generate Certificate:

openssl req -new -x509 -key demo.surekhatech.com.key -out demo.surekhatech.com.cert -days 3650
-subj /CN=demo.surekhatech.com

Once you have SSL key and certificate, you need to update the existing virtual host to run odoo server over “https”. Before that first enable the apache SSL mode by executing below command.

sudo a2enmod ssl

Now open “demo.surekhatech.conf” file from the “/etc/apache2/sites-available” and update the virtual host with the below contents.

	<VirtualHost *:80>
		 ServerName demo.surekhatech.com
		 ServerAlias demo.surekhatech.com
		 Redirect / https://demo.surekhatech.com/
	</VirtualHost>
	
	<VirtualHost *:443>
		 ServerName demo.surekhatech.com
		 ServerAlias demo.surekhatech.com
	
		 LogLevel warn
		 ErrorLog /var/log/apache2/demo.surekhatech.com.error.log
		 CustomLog /var/log/apache2/demo.surekhatech.com.access.log combined
	
		 SSLEngine on
		 SSLProxyEngine on
		 SSLCertificateFile /etc/apache2/ssl/demo.surekhatech.com.cert
		 SSLCertificateKeyFile /etc/apache2/ssl/demo.surekhatech.com.key
	
		 ProxyPreserveHost On
		 ProxyPass / http://localhost:8069/ retry=0
		 ProxyPassReverse / http://localhost:8069/
	</VirtualHost>

Here we have added the path for the SSL certificate and key file. Create a directory with “ssl” name on “/etc/apache2” location. Copy the SSL certificate and key files into “/etc/apache2/ssl” directory.

Now restart the apache web server using the following command. 

sudo service apache2 restart

Open any browser and hit the url “demo.surekhatech.com”. You can see that it will automatically redirect your odoo server over “https”, a more secure channel. Any request to your odoo server will be serve over the “https”.

For more implementation details or support you may contact us at [email protected].

Contact us

For Your Business Requirements

Text to Identify Refresh CAPTCHA
Background Image Close Button

2 - 4 October 2024

Hall: 10, Booth: #B8 Brussels, Belgium