Introduction:
Recently, one of my subscribers reached out with a question about setting up NGINX for Odoo, let's see.. the question was for this odoo setup video.
In this article, we will walk you through the process of setting up a proxy pass with Nginx to an Odoo server and securing the communication with SSL. This step-by-step guide will help you establish a secure connection between Nginx and Odoo, ensuring smooth and protected data transmission.
Table of Contents:
- Installing Nginx
- Configuring Nginx for Odoo Proxy Pass
- Enabling Nginx Configuration
- Testing Nginx Configuration
- Restarting Nginx
- Installing SSL Certificate
- Obtaining SSL Certificate with Certbot
- Post configure in Nginx
Step 1: Installing Nginx
- Update the package list: `sudo apt update`
- Install Nginx: `sudo apt install nginx`
Step 2: Configuring Nginx for Odoo Proxy Pass
- Create a new configuration file for Odoo site
- Define proxy pass settings in the configuration
Create a new file at this location to add nginx proxy for odoo. I am using here odoo.conf
sudo vim /etc/nginx/sites-available/odoo.conf
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
server {
listen 80;
server_name your_domain.com; #Change domain name here
location / {
proxy_pass http://odoo;
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;
}
location /websocket {
proxy_pass http://odoo;
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;
}
location ~* /longpolling {
proxy_pass http://odoochat;
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;
}
}
This is setup for your port 80 with nginx.
Step 3: Enabling Nginx Configuration
- Create a symbolic link to enable the Nginx configuration
sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/
Step 4: Testing Nginx Configuration
- Check the configuration for syntax errors:
sudo nginx -t
Step 5: Restarting Nginx
- Apply the changes by restarting Nginx:
sudo systemctl restart nginx
sudo service nginx restart
Step 6: Installing SSL Certificate
- Install Certbot and Python3-certbot-nginx:
sudo apt install certbot python3-certbot-nginx
Step 7: Obtaining SSL Certificate with Certbot
- Run Certbot to obtain an SSL certificate for your domain:
sudo certbot --nginx domain.com
sudo certbot --nginx
This will asks you few information and certbot will try to automatically configure the SSL, means your port 80 server block will be converted to SSL-443 server block and additional port 80 server block will be added with a redirect to 443. like:
server {
if ($host = 'domain.com') {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name domain.com;
}
Step 8: Post configure
Hope till step 7 your SSL and odoo nginx proxy will be all working. If you are willing to configure additional things in nginx like cache control, compression, writing other web server harden rules you may follow my youtube channel, related with nginx.
Conclusion:
By following the detailed steps outlined in this article, you can successfully set up a proxy pass with Nginx to an Odoo server and enhance security with SSL encryption. This configuration will ensure a secure and efficient communication channel between Nginx and Odoo, providing a seamless user experience.
NGINX Proxy for Odoo ERP Server: Easy Step-by-Step Guide