使用 Nginx 在 Odoo 中重定向的问题

使用 Nginx 在 Odoo 中重定向的问题

我在 Odoo 中重定向时遇到了一些问题。我配置了 Nginx 并安装了 Odoo,但主要问题是我使用外部 IP,从而在不同端口上使用 2 个 odoo 实例。我需要通过端口连接到另一个 odoo 实例。我做到了,只需使用外部 IP + 第二个实例的端口并通过 nginx 重定向。但是当我们第一次尝试连接时,odoo 服务器使用端口 80 的 wsgi 重定向,然后转到第一个实例。如何使用我的端口重定向 odoo,或者最好通过 nginx 尝试?示例:工作:http://test-env:5598/web/login 不工作:http://测试环境:5598/. 它会重定向到http://测试环境:5598/web之后http://test-env/web/login在此处输入图片描述有端口 80。

NGINX 配置:

upstream testodoo-server{
    server 127.0.0.1:8069;
}

upstream testodoo-server-im{
    server 127.0.0.1:8072 weight=1 fail_timeout=0;
}

server {
    listen 80;
    listen [::]:80;
    server_name test-env default;

# Specifies the maximum accepted body size of a client request,
#   as indicated by the request header Content-Length.

proxy_read_timeout 7200s;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
client_max_body_size 500m;
fastcgi_read_timeout 7200s;
fastcgi_send_timeout 7200s;
uwsgi_read_timeout 7200s;

# ssl log files
access_log    /var/log/nginx/testodoo-access.log;
error_log    /var/log/nginx/testodoo-error.log;
keepalive_timeout    90;

# increase proxy buffer to handle some OpenERP web requests
proxy_buffers 16 64k;
proxy_buffer_size 128k;

#general proxy settings
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

# set headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_x_forwarded_host;

# Let the Odoo web service know that we’re using HTTPS, otherwise
# it will generate URL using http:// and not https://
proxy_set_header X-Forwarded-Proto http;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location / {
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass http://testodoo-server;
}
location /longpolling {
    proxy_pass http://testodoo-server-im;
}


# cache some static data in memory for 90mins.
# under heavy load this should relieve stress on the odoo web interface a bit.
location ~* /web/static/ {
    proxy_cache_valid 200 90m;
    proxy_buffering    on;
    expires 864000;
    proxy_pass http://testodoo-server;
}

# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}

odoo 配置:

[options]
; This is the password that allows database operations:
admin_passwd = JsSdfjskak1231dSs
db_host = localhost
db_port = 5432
db_user = testodoo
db_password = testodoo

xmlrpc = True
xmlrpc_interface = 127.0.0.1

proxy_mode = True
netrpc_interface = 127.0.0.1

addons_path =/opt/odoo/dev/myaddons12,/opt/odoo/dev/odoo-12.0/odoo/addons
log_level = debug
logfile = /opt/odoo/dev/log/testodoo.log
webkit_path = /usr/local/bin/wkhtmltopdf
bin_path = /usr/local/bin

limit_memory_hard = 6442450944
limit_memory_soft = 4294967296
limit_request = 8192
limit_time_cpu = 21600
limit_time_real = 1200

相关内容