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: 162.138.2.103 - - [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/http.py", line 1998, in __call__
response = request._serve_db()
File "/opt/odoo16/odoo16/odoo/http.py", line 1584, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/opt/odoo16/odoo16/odoo/service/model.py", line 133, in retrying
result = func()
File "/opt/odoo16/odoo16/odoo/http.py", line 1611, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/opt/odoo16/odoo16/odoo/http.py", line 1725, in dispatch
return self.request.registry['ir.http']._dispatch(endpoint)
File "/opt/odoo16/odoo16/addons/website/models/ir_http.py", line 235, in _dispatch
response = super()._dispatch(endpoint)
File "/opt/odoo16/odoo16/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
result = endpoint(**request.params)
File "/opt/odoo16/odoo16/odoo/http.py", line 697, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/opt/odoo16/odoo16/addons/bus/controllers/websocket.py", line 23, in websocket
return WebsocketConnectionHandler.open_connection(request)
File "/opt/odoo16/odoo16/addons/bus/websocket.py", 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: https://www.odoo.com/documentation/16.0/administration/install/deploy.html
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# http -> https
server {
listen 80;
server_name odoo.mycompany.com;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name odoo.mycompany.com;
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_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
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:
www.example.com {
tls cert@example.com
redir https://example.com
}
example.com {
tls cert@example.com
reverse_proxy 172.0.0.1:8069
}