Configuring Longpolling for Odoo 15 Nginx (jwilder)

This guide explains how to configure longpolling for an Odoo 15 instance using Nginx (jwilder) as a reverse proxy. Longpolling allows Odoo to handle real-time notifications efficiently, enabling features like live chat and instant updates.

Step 1: Adding the Configuration File

To integrate the longpolling configuration into the Nginx reverse proxy, we first need to mount a custom configuration file. In your docker-compose.yml file, add the following volume under the nginx service:

volumes:
  - ./nginx/confs/kissa15.conf:/etc/nginx/conf.d/kissa15.conf

This ensures that the custom configuration file kissa15.conf is loaded into Nginx inside the Docker container.

Step 2: Creating the Longpolling Upstream Configuration

  • Next, create the file kissa15.conf inside the nginx/confs/ directory:
upstream kissa.dz-longpolling {               
    server 10.5.0.13:8072;  # Use the longpolling port here  
  • Explanation:
  • upstream kissa.dz-longpolling defines a named upstream group.
  • server 10.5.0.13:8072; specifies the Odoo longpolling service running on port 8072.

Step 3: Configuring the Virtual Host

  • Navigate to service.nginx/nginx/vhost.d/ and create a file named kissa.dz. This file will contain specific configurations for handling longpolling requests.
  • File Content:
# Add these proxy settings to optimize performance
proxy_buffers 16 64k;
proxy_buffer_size 128k;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_send_timeout 300;
 
# Add the longpolling location
location /longpolling {
    proxy_pass http://kissa.dz-longpolling;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    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 600s;
    proxy_connect_timeout 600s;
}
  • Explanation:
  • The proxy_buffers and proxy_buffer_size settings improve proxy performance.
  • The proxy_read_timeout, proxy_connect_timeout, and proxy_send_timeout prevent timeouts during longpolling requests.
  • The location /longpolling block configures Nginx to forward WebSocket-based longpolling requests to the upstream server (kissa.dz-longpolling).
  • The proxy_set_header directives ensure proper WebSocket handling and preserve client IP addresses.

Step 4: Restarting Nginx Proxy

After making the changes, restart the Nginx proxy container to apply the configuration:

docker-compose up && docker-compose down

To validate the configuration, run:

docker exec -it nginx-proxy nginx -t

If the configuration is correct, you should see:

nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, reload the Nginx service inside the container:

docker exec -i nginx-proxy nginx -s reload

Step 5: Verifying Longpolling

Once the configuration is applied, your Odoo 15 instance should now be able to use longpolling effectively, improving real-time interactions such as:

  1. Live chat responsiveness
  2. Instant notifications
  3. Efficient handling of background events

Note

  • Longpolling configuration was mainly added for workers activation , in kissa's case activating workers would result in POS (Point of sale) crushing
  • and here is the current odoo.conf configuration that works with longpolling
[options]
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
proxy_mode = True
db_maxconn = 300
limit_memory_hard = 17180000000
limit_memory_soft = 8589000000
limit_request = 81920
limit_time_cpu = 6000
limit_time_real = 1200
max_cron_threads = 3
workers = 10
max_xmlrpc_threads = 2

Conclusion

  • By following these steps, you have successfully configured longpolling for Odoo 15 using Nginx (jwilder) as a reverse proxy. This setup ensures that your Odoo instance can handle real-time features efficiently while maintaining performance and stability.

— Nadir Habib 2025/03/10 12:29

  • clientsdoc/kissa.txt
  • Last modified: 2025/03/10 12:30
  • by nadir