尝试为 Odoo 设置反向代理时出现过多重定向错误

尝试为 Odoo 设置反向代理时出现过多重定向错误

我正在为我的 Odoo 服务设置反向代理,但收到“重定向过多”的错误。我正在使用 Cloudflare 及其将放置在 nginx 反向代理上的原始证书。以下是我最新的 NGiNX 配置,由于重定向过多而失败:

#odoo server
upstream odoo {
server 192.168.4.100:8069;
}
upstream odoochat {
server 192.168.4.100:8072;
}

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

server {
listen 443 ssl http2;
server_name erp.mydomain.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;

# 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;

# SSL parameters
ssl_certificate /etc/cloudflare/mydomain/odoo/cert.pem;
ssl_certificate_key /etc/cloudflare/mydomain/odoo/key.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
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 longpoll requests to odoo longpolling port
location /longpolling {
proxy_pass http://odoochat;
}

# Redirect requests to odoo backend server
location / {
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;
}

如果我设置 http,它就能正常连接。即 HTTPS:[CLOUDFLARE] --> HTTP:[ORIGIN_SERVER] 我想要的是 HTTPS:[CLOUDFLARE --> HTTPS:[ORIGIN_SERVER] 但我收到的重定向太多了。

相关内容