Search code examples
pythondockernginxdocker-composeodoo

I can't run odoo on nginx using docker


I am trying to run odoo on nginx in docker but the page is giving me an error. my docker compose (https://i.sstatic.net/19Z6aEW3.png) my configuration ngix (https://i.sstatic.net/jt5bGLPF.png) web error (https://i.sstatic.net/wicVvG3Y.png) I want to run odoo on nginx to apply the advantages that this has. If someone could help me I would be very grateful for it.


Solution

  • 🗎 docker-compose.yml (Simplified version without some volume mounts.)

    version: '3.1'
    services:
      odoo_v2:
        image: odoo:17
        depends_on:
          - db_v2
        environment:
          - HOST=db_v2
          - USER=odoo
          - PASSWORD=odoo
        ports:
          - 8069:8069
    
      db_v2:
        image: postgres:15
        environment:
          - POSTGRES_DB=postgres
          - POSTGRES_PASSWORD=odoo
          - POSTGRES_USER=odoo
    
      nginx:
        image: nginx
        ports:
          - 80:80
        volumes:
          - ./nginx:/etc/nginx/conf.d
        depends_on:
          - odoo_v2
    
    volumes:
      odoo-web-data:
    

    🗎 nginx/default.conf

    upstream odoo {
        server odoo_v2:8069;
    }
    upstream odoochat {
        server odoo_v2:8072;
    }
    
    server {
        listen 80 default_server;
        listen [::]:80 default_server;
    
        server_name _;
    
        location / {
            proxy_redirect http://odoo/ http://$host/;
            proxy_pass http://odoo;
        }
    
        location /longpolling {
            proxy_pass http://odoochat;
        }
    
        access_log /var/log/nginx/odoo.access.log;
        error_log /var/log/nginx/odoo.error.log;
    }
    

    Go to http://localhost/.

    enter image description here