Adding a domain name to Odoo Community Edition and configuring Nginx as a reverse proxy
Adding a Domain Name and Nginx proxy server
Step 1: Install Odoo 17 Community Edition:
Step 2: Configure the Domain Name
1. Purchase a Domain Name
- Use a domain registrar to buy a domain name (e.g., xyz.com).
2. Set Up DNS Records
- Point your domain to your server’s IP address by configuring the DNS A records. This is typically done through your domain registrar’s control panel.
- Set an A record for your domain (e.g.,
example.com
) pointing to your server's public IP address.
Step 3: Install Nginx
If you haven't installed Nginx yet, you can do so with the following command:
sudo apt update
sudo apt install nginx
Step 4: Configure Nginx for Odoo
1. Create an Nginx Configuration File
Create a new configuration file in /etc/nginx/sites-available/
. You can name it after your domain or odoo_server.conf (e.g., xyz.com
):
2. Add Configuration Settings
Add the following configuration to the file, adjusting example.com
to your domain name and /path/to/odoo
to the path where Odoo is installed:
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
server {
listen 80;
server_name xyz.com www.xyz.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Add Headers for odoo proxy mode
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# log
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
# Redirect requests to odoo backend server
location / {
proxy_redirect off;
proxy_pass http://odoo;
}
location /longpolling {
proxy_pass http://odoochat;
}
# common gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 500M;
sendfile on;
send_timeout 600s;
keepalive_timeout 300;
}
3. Enable the Configuration
Create a symbolic link to the sites-enabled directory:
sudo ln -s /etc/nginx/sites-available/xyz.com /etc/nginx/sites-enabled/
4. Test the Nginx Configuration
Test to ensure there are no syntax errors in your configuration:
sudo nginx -t
5. Restart Nginx
Restart Nginx to apply the changes:
Step 5: Update Odoo Configuration
1. Edit the Odoo Configuration File
- Open your Odoo configuration file, usually located at
/etc/odoo/odoo.conf
:
- Ensure that the following line is added to enable the proxy mode:
proxy_mode = True
Step 6: Access Odoo
- Open your web browser and go to
http://xyz.com
. You should see the Odoo login screen.
Step 7: (Optional) Enable HTTPS
To secure your connection, it’s advisable to use HTTPS. You can use Let’s Encrypt to obtain a free SSL certificate:
1. Install Certbot
sudo apt install certbot python3-certbot-nginx
2. Obtain an SSL Certificate
sudo certbot --nginx -d xyz.com -d www.xyz.com
3. Auto-Renewal
Ensure that Certbot automatically renews your certificate:
sudo certbot renew --dry-run
Conclusion
You have successfully configured your domain name to point to Odoo 17 Community Edition using Nginx as a reverse proxy. This setup ensures that users can access your Odoo instance via a domain name, and you can optionally secure it with SSL for enhanced security.
Feel free to ask if you need more specific details or if you encounter any issues!
Comments