Wellington Souza
Wellington Souza

Reputation: 2368

Odoo using Traefik proxy instead of Nginx

I have successfully used Traefik for several containerized applications and I am happy with the native SSL support using LetsEncrypt (Thank you very much Traefik team). However, specifically, to run Odoo (Open-source ERP/CRM), I am getting an exception in the back-end and also in the browser via javascript logs: Exception: bus.Bus unavailable + the call stack not important here. Apparently, the root cause of this exception is that Traefik is not proxying the requests coming to the URL /longpolling when the parameter workers > 1 in the odoo.conf file.

The Odoo server exposes two different ports:

I made a GitHub Repository explaining how to reproduce this "bug" (I don't know if it's a bug or if I don't know how to use it properly).

As a reference, I also added one nginx.conf file not using SSL (just to make it simple).

Here is my docker-compose.yml used to run Odoo + Traefik:

version: "2.3"
networks:
  web:
    external: true

services:
  traefik:
    image: "traefik:v2.4"
    container_name: "traefik"
    env_file: .env
    environment:
      - UID=2000
      - GID=2000
    ports:
      - "80:80"
      - "443:443"
    command:
      - --api.insecure=true
      - --api.dashboard=true
      - --api.debug=true
      - --log=true
      - --log.level=INFO
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --providers.file.filename=/dynamic.yml
      - --providers.docker.network=web
      - --entrypoints.http.address=:80
      - --entrypoints.https.address=:443
      - --certificatesresolvers.le.acme.httpchallenge=true
      - --certificatesresolvers.le.acme.httpchallenge.entrypoint=http
      - --certificatesresolvers.le.acme.email=${LETS_ENCRYPT_CONTACT_EMAIL}
      - --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
    networks:
      - web
    volumes:
      - "${BASE_VOLUME_DIR}/traefik/conf/letsencrypt:/letsencrypt"
      - "${BASE_VOLUME_DIR}/traefik/conf/dynamic.yml:/dynamic.yml"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    labels:  
      - traefik.enable=true
      - traefik.http.routers.traefik-http.rule=Host(`${TRAEFIK_HOSTNAME}`)
      - traefik.http.routers.traefik-http.entrypoints=http
      - traefik.http.routers.traefik-http.service=traefik
      - traefik.http.routers.traefik-http.middlewares=redirect@file
      - traefik.http.routers.traefik-https.rule=Host(`${TRAEFIK_HOSTNAME}`)
      - traefik.http.routers.traefik-https.entrypoints=https
      - traefik.http.routers.traefik-https.tls=true
      - traefik.http.routers.traefik-https.tls.options=default
      - traefik.http.routers.traefik-https.service=traefik
      - traefik.http.routers.traefik-https.tls.certresolver=le
      - traefik.http.services.traefik.loadbalancer.server.port=8080
      - traefik.http.routers.traefik-https.middlewares=gzip
      - traefik.http.middlewares.gzip.compress=true

  odoo:
    image: registry.wisecoding.io/docker/odoo:11.0
    container_name: odoo
    networks:
      - web
    env_file: .env
    ports:
      - "8069:8069"
      - "8072:8072"
    volumes:
      - "${BASE_VOLUME_DIR}/odoo/extra-addons:/opt/odoo/extra-addons"
      - "${BASE_VOLUME_DIR}/odoo/data:/opt/odoo/data"
      - "${BASE_VOLUME_DIR}/odoo/logs:/opt/odoo/logs"
      - "${BASE_VOLUME_DIR}/odoo/conf:/opt/odoo/conf"
    ulimits:
      nofile:
        soft: 65536
        hard: 65536
    labels:
      - traefik.enable=true
      - traefik.http.routers.odoo-http.rule=Host(`${ODOO_HOSTNAME}`)
      - traefik.http.routers.odoo-http.entrypoints=http
      - traefik.http.routers.odoo-http.service=odoo-http
      - traefik.http.services.odoo-http.loadbalancer.server.port=8069
      - traefik.http.routers.odoo-http.middlewares=redirect@file
      - traefik.http.routers.odoo-https.rule=Host(`${ODOO_HOSTNAME}`)
      - traefik.http.routers.odoo-https.entrypoints=https
      - traefik.http.routers.odoo-https.service=odoo-https
      - traefik.http.routers.odoo-https.tls.certresolver=le
      - traefik.http.routers.odoo-https.middlewares=gzip
      - traefik.http.services.odoo-https.loadbalancer.server.port=8069

       #====> On the next line was my mistake. It was typo as pointed out by @Veikko
      - traefik.http.routers.odoo-im-https.rule=Host(`${ODOO_HOSTNAME}`) && (PathPrefix(`/longpooling`))
      - traefik.http.routers.odoo-im-https.entrypoints=https
      - traefik.http.routers.odoo-im-https.service=odoo-im-https
      - traefik.http.routers.odoo-im-https.tls.certresolver=le
      - traefik.http.routers.odoo-im-https.middlewares=gzip,sslheader
      - traefik.http.services.odoo-im-https.loadbalancer.server.port=8072

      # middlewares
      - traefik.http.middlewares.gzip.compress=true
      - traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https

The closest solution that I found was on this question on the Traefik forum, suggesting to include the line below (which I tried, but still did not work): traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto = https

I may have missed something, but I could not figure it out.

Thoughts?

Upvotes: 0

Views: 2116

Answers (1)

Veikko
Veikko

Reputation: 3620

Correct Odoo url path is /longpolling. Check that your Traefik and Odoo configurations use longpolling, not longpooling, e.g. the Odoo container labels for Traefik ...PathPrefix('/longpooling')" -> ...PathPrefix('/longpolling')".

Upvotes: 1

Related Questions