Configuring Nginx with Odoo

Reverse proxy and more

So you want to run Odoo under your domain? Not a problem. In order to do that, you can use Apache (see the tutorial here) or Nginx. This tutorial is step by step guide how to configure Odoo nginx to work with Odoo. If you are installing Odoo on the server which is already hosting some websites you should use the current software.

Please note, that if you want to use nginx and you are already using Apache you will have to stop Apache (systemctl stop apache2) and probably remove it (apt-get purge apache2apt autoremove). If you don't know it yet - before you start change the mode sudo su.

1. Update the system (I know it is not necessary but it is a common practice):

apt-get update

2. Install nginx:

apt-get install nginx

3. Enable and run the thing:

systemctl start nginx
systemctl enable nginx

4. Now it is time to configure:

nano etc/nginx/sites-available/yoursite.com


server {

listen 80;

server_name http://yoursite.com;

location / {

proxy_pass http://0.0.0.0:8069;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_read_timeout 3000000;

client_max_body_size 2000M;

}

# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

}

5. Create a shortcut in sites-enabled :

ln -s /etc/nginx/sites-available/yoursite.com /etc/nginx/sites-enabled/yoursite.com

6. You can now remove the default configuration:

rm -f /etc/nginx/sites-enabled/default

7. Test the Nginx and restart to apply the changes:

nginx -t
service nginx restart