Caddyfile setting for ODOO16 with KeyError socket Caddy V2

1. The problem I’m having:

ODOO 16 installed on ubuntu and reverse proxy via Caddy v2;
in odoo log, there is always an error message as below, it looks like my setting in caddyfile is't enough.

2. Error messages and/or full log output:

2023-07-31 08:57:35,079 2573 INFO ODOOHOST werkzeug: - - [31/Jul/2023 08:57:35] "GET /websocket HTTP/1.1" 500 - 1 0.000 0.002
2023-07-31 08:57:43,339 2569 ERROR ODOOHOST odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/opt/odoo16/odoo16/odoo/", line 1998, in __call__
    response = request._serve_db()
  File "/opt/odoo16/odoo16/odoo/", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo16/odoo16/odoo/service/", line 133, in retrying
    result = func()
  File "/opt/odoo16/odoo16/odoo/", line 1611, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo16/odoo16/odoo/", line 1725, in dispatch
    return self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo16/odoo16/addons/website/models/", line 235, in _dispatch
    response = super()._dispatch(endpoint)
  File "/opt/odoo16/odoo16/odoo/addons/base/models/", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo16/odoo16/odoo/", line 697, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo16/odoo16/addons/bus/controllers/", line 23, in websocket
    return WebsocketConnectionHandler.open_connection(request)
  File "/opt/odoo16/odoo16/addons/bus/", line 817, in open_connection
    Websocket(request.httprequest.environ['socket'], request.session),
KeyError: 'socket'

3. Caddy version:

Caddy version v2.64

4. How I installed and ran Caddy:

Cadyy is installed on Docker

a. System environment:

the corect settings for nginx file from  ODOO offiical website is shown below:

#odoo server
upstream odoo {
upstream odoochat {
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;

# http -> https
server {
  listen 80;
  rewrite ^(.*) https://$host$1 permanent;

server {
  listen 443 ssl;
  proxy_read_timeout 720s;
  proxy_connect_timeout 720s;
  proxy_send_timeout 720s;

  # SSL parameters
  ssl_certificate /etc/ssl/nginx/server.crt;
  ssl_certificate_key /etc/ssl/nginx/server.key;
  ssl_session_timeout 30m;
  ssl_protocols TLSv1.2;
  ssl_prefer_server_ciphers off;

  # log
  access_log /var/log/nginx/odoo.access.log;
  error_log /var/log/nginx/odoo.error.log;

  # Redirect websocket requests to odoo gevent port
  location /websocket {
    proxy_pass http://odoochat;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    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;

  # Redirect requests to odoo backend server
  location / {
    # 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;
    proxy_redirect off;
    proxy_pass http://odoo;

  # common gzip
  gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
  gzip on;

b. Command:

can anyone help to translate / convert the above nginx file to Caddy v2 file.  thank you!

d. My complete Caddy config: {
} {


} {
} {
	encode gzip
	reverse_proxy /websocket*

That should be all you need.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.